fipy package¶
Subpackages¶
- fipy.boundaryConditions package
- fipy.matrices package
- fipy.meshes package
- Subpackages
- Submodules
- fipy.meshes.abstractMesh module
AbstractMeshAbstractMesh.VTKCellDataSetAbstractMesh.VTKFaceDataSetAbstractMesh.__add__()AbstractMesh.__div__()AbstractMesh.__getstate__()AbstractMesh.__mul__()AbstractMesh.__radd__()AbstractMesh.__repr__()AbstractMesh.__rmul__()AbstractMesh.__setstate__()AbstractMesh.__sub__()AbstractMesh.__truediv__()AbstractMesh.aspect2DAbstractMesh.cellCentersAbstractMesh.cellDistanceVectorsAbstractMesh.cellFaceIDsAbstractMesh.cellToFaceDistanceVectorsAbstractMesh.cellVolumesAbstractMesh.extentsAbstractMesh.exteriorFacesAbstractMesh.faceCentersAbstractMesh.facesBackAbstractMesh.facesBottomAbstractMesh.facesDownAbstractMesh.facesFrontAbstractMesh.facesLeftAbstractMesh.facesRightAbstractMesh.facesTopAbstractMesh.facesUpAbstractMesh.getNearestCell()AbstractMesh.interiorFaceCellIDsAbstractMesh.interiorFaceIDsAbstractMesh.interiorFacesAbstractMesh.scaleAbstractMesh.scaledCellDistancesAbstractMesh.scaledCellToCellDistancesAbstractMesh.scaledCellVolumesAbstractMesh.scaledFaceAreasAbstractMesh.scaledFaceToCellDistancesAbstractMesh.xAbstractMesh.yAbstractMesh.z
- fipy.meshes.cylindricalGrid1D module
- fipy.meshes.cylindricalGrid2D module
- fipy.meshes.cylindricalNonUniformGrid1D module
CylindricalNonUniformGrid1DCylindricalNonUniformGrid1D.VTKCellDataSetCylindricalNonUniformGrid1D.VTKFaceDataSetCylindricalNonUniformGrid1D.__add__()CylindricalNonUniformGrid1D.__div__()CylindricalNonUniformGrid1D.__getstate__()CylindricalNonUniformGrid1D.__mul__()CylindricalNonUniformGrid1D.__radd__()CylindricalNonUniformGrid1D.__repr__()CylindricalNonUniformGrid1D.__rmul__()CylindricalNonUniformGrid1D.__setstate__()CylindricalNonUniformGrid1D.__sub__()CylindricalNonUniformGrid1D.__truediv__()CylindricalNonUniformGrid1D.aspect2DCylindricalNonUniformGrid1D.cellCentersCylindricalNonUniformGrid1D.cellDistanceVectorsCylindricalNonUniformGrid1D.cellFaceIDsCylindricalNonUniformGrid1D.cellToFaceDistanceVectorsCylindricalNonUniformGrid1D.cellVolumesCylindricalNonUniformGrid1D.extentsCylindricalNonUniformGrid1D.exteriorFacesCylindricalNonUniformGrid1D.faceCentersCylindricalNonUniformGrid1D.facesBackCylindricalNonUniformGrid1D.facesBottomCylindricalNonUniformGrid1D.facesDownCylindricalNonUniformGrid1D.facesFrontCylindricalNonUniformGrid1D.facesLeftCylindricalNonUniformGrid1D.facesRightCylindricalNonUniformGrid1D.facesTopCylindricalNonUniformGrid1D.facesUpCylindricalNonUniformGrid1D.getNearestCell()CylindricalNonUniformGrid1D.interiorFaceCellIDsCylindricalNonUniformGrid1D.interiorFaceIDsCylindricalNonUniformGrid1D.interiorFacesCylindricalNonUniformGrid1D.scaleCylindricalNonUniformGrid1D.scaledCellDistancesCylindricalNonUniformGrid1D.scaledCellToCellDistancesCylindricalNonUniformGrid1D.scaledCellVolumesCylindricalNonUniformGrid1D.scaledFaceAreasCylindricalNonUniformGrid1D.scaledFaceToCellDistancesCylindricalNonUniformGrid1D.xCylindricalNonUniformGrid1D.yCylindricalNonUniformGrid1D.z
- fipy.meshes.cylindricalNonUniformGrid2D module
CylindricalNonUniformGrid2DCylindricalNonUniformGrid2D.VTKCellDataSetCylindricalNonUniformGrid2D.VTKFaceDataSetCylindricalNonUniformGrid2D.__add__()CylindricalNonUniformGrid2D.__div__()CylindricalNonUniformGrid2D.__getstate__()CylindricalNonUniformGrid2D.__mul__()CylindricalNonUniformGrid2D.__radd__()CylindricalNonUniformGrid2D.__repr__()CylindricalNonUniformGrid2D.__rmul__()CylindricalNonUniformGrid2D.__setstate__()CylindricalNonUniformGrid2D.__sub__()CylindricalNonUniformGrid2D.__truediv__()CylindricalNonUniformGrid2D.aspect2DCylindricalNonUniformGrid2D.cellCentersCylindricalNonUniformGrid2D.cellDistanceVectorsCylindricalNonUniformGrid2D.cellFaceIDsCylindricalNonUniformGrid2D.cellToFaceDistanceVectorsCylindricalNonUniformGrid2D.cellVolumesCylindricalNonUniformGrid2D.extentsCylindricalNonUniformGrid2D.exteriorFacesCylindricalNonUniformGrid2D.extrude()CylindricalNonUniformGrid2D.faceCentersCylindricalNonUniformGrid2D.facesBackCylindricalNonUniformGrid2D.facesBottomCylindricalNonUniformGrid2D.facesDownCylindricalNonUniformGrid2D.facesFrontCylindricalNonUniformGrid2D.facesLeftCylindricalNonUniformGrid2D.facesRightCylindricalNonUniformGrid2D.facesTopCylindricalNonUniformGrid2D.facesUpCylindricalNonUniformGrid2D.getNearestCell()CylindricalNonUniformGrid2D.interiorFaceCellIDsCylindricalNonUniformGrid2D.interiorFaceIDsCylindricalNonUniformGrid2D.interiorFacesCylindricalNonUniformGrid2D.scaleCylindricalNonUniformGrid2D.scaledCellDistancesCylindricalNonUniformGrid2D.scaledCellToCellDistancesCylindricalNonUniformGrid2D.scaledCellVolumesCylindricalNonUniformGrid2D.scaledFaceAreasCylindricalNonUniformGrid2D.scaledFaceToCellDistancesCylindricalNonUniformGrid2D.xCylindricalNonUniformGrid2D.yCylindricalNonUniformGrid2D.z
- fipy.meshes.cylindricalUniformGrid1D module
CylindricalUniformGrid1DCylindricalUniformGrid1D.VTKCellDataSetCylindricalUniformGrid1D.VTKFaceDataSetCylindricalUniformGrid1D.__add__()CylindricalUniformGrid1D.__div__()CylindricalUniformGrid1D.__getstate__()CylindricalUniformGrid1D.__mul__()CylindricalUniformGrid1D.__radd__()CylindricalUniformGrid1D.__repr__()CylindricalUniformGrid1D.__rmul__()CylindricalUniformGrid1D.__setstate__()CylindricalUniformGrid1D.__sub__()CylindricalUniformGrid1D.__truediv__()CylindricalUniformGrid1D.aspect2DCylindricalUniformGrid1D.cellCentersCylindricalUniformGrid1D.cellDistanceVectorsCylindricalUniformGrid1D.cellFaceIDsCylindricalUniformGrid1D.cellToFaceDistanceVectorsCylindricalUniformGrid1D.cellVolumesCylindricalUniformGrid1D.extentsCylindricalUniformGrid1D.exteriorFacesCylindricalUniformGrid1D.faceCellIDsCylindricalUniformGrid1D.faceCentersCylindricalUniformGrid1D.faceNormalsCylindricalUniformGrid1D.facesBackCylindricalUniformGrid1D.facesBottomCylindricalUniformGrid1D.facesDownCylindricalUniformGrid1D.facesFrontCylindricalUniformGrid1D.facesLeftCylindricalUniformGrid1D.facesRightCylindricalUniformGrid1D.facesTopCylindricalUniformGrid1D.facesUpCylindricalUniformGrid1D.getNearestCell()CylindricalUniformGrid1D.interiorFaceCellIDsCylindricalUniformGrid1D.interiorFaceIDsCylindricalUniformGrid1D.interiorFacesCylindricalUniformGrid1D.scaleCylindricalUniformGrid1D.scaledCellDistancesCylindricalUniformGrid1D.scaledCellToCellDistancesCylindricalUniformGrid1D.scaledCellVolumesCylindricalUniformGrid1D.scaledFaceAreasCylindricalUniformGrid1D.scaledFaceToCellDistancesCylindricalUniformGrid1D.vertexCoordsCylindricalUniformGrid1D.xCylindricalUniformGrid1D.yCylindricalUniformGrid1D.z
- fipy.meshes.cylindricalUniformGrid2D module
CylindricalUniformGrid2DCylindricalUniformGrid2D.VTKCellDataSetCylindricalUniformGrid2D.VTKFaceDataSetCylindricalUniformGrid2D.__add__()CylindricalUniformGrid2D.__div__()CylindricalUniformGrid2D.__getstate__()CylindricalUniformGrid2D.__mul__()CylindricalUniformGrid2D.__radd__()CylindricalUniformGrid2D.__repr__()CylindricalUniformGrid2D.__rmul__()CylindricalUniformGrid2D.__setstate__()CylindricalUniformGrid2D.__sub__()CylindricalUniformGrid2D.__truediv__()CylindricalUniformGrid2D.aspect2DCylindricalUniformGrid2D.cellCentersCylindricalUniformGrid2D.cellDistanceVectorsCylindricalUniformGrid2D.cellFaceIDsCylindricalUniformGrid2D.cellToFaceDistanceVectorsCylindricalUniformGrid2D.cellVolumesCylindricalUniformGrid2D.extentsCylindricalUniformGrid2D.exteriorFacesCylindricalUniformGrid2D.faceCellIDsCylindricalUniformGrid2D.faceCentersCylindricalUniformGrid2D.faceNormalsCylindricalUniformGrid2D.faceVertexIDsCylindricalUniformGrid2D.facesBackCylindricalUniformGrid2D.facesBottomCylindricalUniformGrid2D.facesDownCylindricalUniformGrid2D.facesFrontCylindricalUniformGrid2D.facesLeftCylindricalUniformGrid2D.facesRightCylindricalUniformGrid2D.facesTopCylindricalUniformGrid2D.facesUpCylindricalUniformGrid2D.getNearestCell()CylindricalUniformGrid2D.interiorFaceCellIDsCylindricalUniformGrid2D.interiorFaceIDsCylindricalUniformGrid2D.interiorFacesCylindricalUniformGrid2D.scaleCylindricalUniformGrid2D.scaledCellDistancesCylindricalUniformGrid2D.scaledCellToCellDistancesCylindricalUniformGrid2D.scaledCellVolumesCylindricalUniformGrid2D.scaledFaceAreasCylindricalUniformGrid2D.scaledFaceToCellDistancesCylindricalUniformGrid2D.vertexCoordsCylindricalUniformGrid2D.xCylindricalUniformGrid2D.yCylindricalUniformGrid2D.z
- fipy.meshes.factoryMeshes module
- fipy.meshes.gmshMesh module
Gmsh2DGmsh2D.VTKCellDataSetGmsh2D.VTKFaceDataSetGmsh2D.__add__()Gmsh2D.__div__()Gmsh2D.__getstate__()Gmsh2D.__mul__()Gmsh2D.__radd__()Gmsh2D.__repr__()Gmsh2D.__rmul__()Gmsh2D.__setstate__()Gmsh2D.__sub__()Gmsh2D.__truediv__()Gmsh2D.aspect2DGmsh2D.cellCentersGmsh2D.cellDistanceVectorsGmsh2D.cellFaceIDsGmsh2D.cellToFaceDistanceVectorsGmsh2D.cellVolumesGmsh2D.extentsGmsh2D.exteriorFacesGmsh2D.extrude()Gmsh2D.faceCentersGmsh2D.facesBackGmsh2D.facesBottomGmsh2D.facesDownGmsh2D.facesFrontGmsh2D.facesLeftGmsh2D.facesRightGmsh2D.facesTopGmsh2D.facesUpGmsh2D.getNearestCell()Gmsh2D.interiorFaceCellIDsGmsh2D.interiorFaceIDsGmsh2D.interiorFacesGmsh2D.scaleGmsh2D.scaledCellDistancesGmsh2D.scaledCellToCellDistancesGmsh2D.scaledCellVolumesGmsh2D.scaledFaceAreasGmsh2D.scaledFaceToCellDistancesGmsh2D.xGmsh2D.yGmsh2D.z
Gmsh2DIn3DSpaceGmsh2DIn3DSpace.VTKCellDataSetGmsh2DIn3DSpace.VTKFaceDataSetGmsh2DIn3DSpace.__add__()Gmsh2DIn3DSpace.__div__()Gmsh2DIn3DSpace.__getstate__()Gmsh2DIn3DSpace.__mul__()Gmsh2DIn3DSpace.__radd__()Gmsh2DIn3DSpace.__repr__()Gmsh2DIn3DSpace.__rmul__()Gmsh2DIn3DSpace.__setstate__()Gmsh2DIn3DSpace.__sub__()Gmsh2DIn3DSpace.__truediv__()Gmsh2DIn3DSpace.aspect2DGmsh2DIn3DSpace.cellCentersGmsh2DIn3DSpace.cellDistanceVectorsGmsh2DIn3DSpace.cellFaceIDsGmsh2DIn3DSpace.cellToFaceDistanceVectorsGmsh2DIn3DSpace.cellVolumesGmsh2DIn3DSpace.extentsGmsh2DIn3DSpace.exteriorFacesGmsh2DIn3DSpace.extrude()Gmsh2DIn3DSpace.faceCentersGmsh2DIn3DSpace.facesBackGmsh2DIn3DSpace.facesBottomGmsh2DIn3DSpace.facesDownGmsh2DIn3DSpace.facesFrontGmsh2DIn3DSpace.facesLeftGmsh2DIn3DSpace.facesRightGmsh2DIn3DSpace.facesTopGmsh2DIn3DSpace.facesUpGmsh2DIn3DSpace.getNearestCell()Gmsh2DIn3DSpace.interiorFaceCellIDsGmsh2DIn3DSpace.interiorFaceIDsGmsh2DIn3DSpace.interiorFacesGmsh2DIn3DSpace.scaleGmsh2DIn3DSpace.scaledCellDistancesGmsh2DIn3DSpace.scaledCellToCellDistancesGmsh2DIn3DSpace.scaledCellVolumesGmsh2DIn3DSpace.scaledFaceAreasGmsh2DIn3DSpace.scaledFaceToCellDistancesGmsh2DIn3DSpace.xGmsh2DIn3DSpace.yGmsh2DIn3DSpace.z
Gmsh3DGmsh3D.VTKCellDataSetGmsh3D.VTKFaceDataSetGmsh3D.__add__()Gmsh3D.__div__()Gmsh3D.__getstate__()Gmsh3D.__mul__()Gmsh3D.__radd__()Gmsh3D.__repr__()Gmsh3D.__rmul__()Gmsh3D.__setstate__()Gmsh3D.__sub__()Gmsh3D.__truediv__()Gmsh3D.aspect2DGmsh3D.cellCentersGmsh3D.cellDistanceVectorsGmsh3D.cellFaceIDsGmsh3D.cellToFaceDistanceVectorsGmsh3D.cellVolumesGmsh3D.extentsGmsh3D.exteriorFacesGmsh3D.faceCentersGmsh3D.facesBackGmsh3D.facesBottomGmsh3D.facesDownGmsh3D.facesFrontGmsh3D.facesLeftGmsh3D.facesRightGmsh3D.facesTopGmsh3D.facesUpGmsh3D.getNearestCell()Gmsh3D.interiorFaceCellIDsGmsh3D.interiorFaceIDsGmsh3D.interiorFacesGmsh3D.scaleGmsh3D.scaledCellDistancesGmsh3D.scaledCellToCellDistancesGmsh3D.scaledCellVolumesGmsh3D.scaledFaceAreasGmsh3D.scaledFaceToCellDistancesGmsh3D.xGmsh3D.yGmsh3D.z
GmshGrid2DGmshGrid2D.VTKCellDataSetGmshGrid2D.VTKFaceDataSetGmshGrid2D.__add__()GmshGrid2D.__div__()GmshGrid2D.__getstate__()GmshGrid2D.__mul__()GmshGrid2D.__radd__()GmshGrid2D.__repr__()GmshGrid2D.__rmul__()GmshGrid2D.__setstate__()GmshGrid2D.__sub__()GmshGrid2D.__truediv__()GmshGrid2D.aspect2DGmshGrid2D.cellCentersGmshGrid2D.cellDistanceVectorsGmshGrid2D.cellFaceIDsGmshGrid2D.cellToFaceDistanceVectorsGmshGrid2D.cellVolumesGmshGrid2D.extentsGmshGrid2D.exteriorFacesGmshGrid2D.extrude()GmshGrid2D.faceCentersGmshGrid2D.facesBackGmshGrid2D.facesBottomGmshGrid2D.facesDownGmshGrid2D.facesFrontGmshGrid2D.facesLeftGmshGrid2D.facesRightGmshGrid2D.facesTopGmshGrid2D.facesUpGmshGrid2D.getNearestCell()GmshGrid2D.interiorFaceCellIDsGmshGrid2D.interiorFaceIDsGmshGrid2D.interiorFacesGmshGrid2D.scaleGmshGrid2D.scaledCellDistancesGmshGrid2D.scaledCellToCellDistancesGmshGrid2D.scaledCellVolumesGmshGrid2D.scaledFaceAreasGmshGrid2D.scaledFaceToCellDistancesGmshGrid2D.xGmshGrid2D.yGmshGrid2D.z
GmshGrid3DGmshGrid3D.VTKCellDataSetGmshGrid3D.VTKFaceDataSetGmshGrid3D.__add__()GmshGrid3D.__div__()GmshGrid3D.__getstate__()GmshGrid3D.__mul__()GmshGrid3D.__radd__()GmshGrid3D.__repr__()GmshGrid3D.__rmul__()GmshGrid3D.__setstate__()GmshGrid3D.__sub__()GmshGrid3D.__truediv__()GmshGrid3D.aspect2DGmshGrid3D.cellCentersGmshGrid3D.cellDistanceVectorsGmshGrid3D.cellFaceIDsGmshGrid3D.cellToFaceDistanceVectorsGmshGrid3D.cellVolumesGmshGrid3D.extentsGmshGrid3D.exteriorFacesGmshGrid3D.faceCentersGmshGrid3D.facesBackGmshGrid3D.facesBottomGmshGrid3D.facesDownGmshGrid3D.facesFrontGmshGrid3D.facesLeftGmshGrid3D.facesRightGmshGrid3D.facesTopGmshGrid3D.facesUpGmshGrid3D.getNearestCell()GmshGrid3D.interiorFaceCellIDsGmshGrid3D.interiorFaceIDsGmshGrid3D.interiorFacesGmshGrid3D.scaleGmshGrid3D.scaledCellDistancesGmshGrid3D.scaledCellToCellDistancesGmshGrid3D.scaledCellVolumesGmshGrid3D.scaledFaceAreasGmshGrid3D.scaledFaceToCellDistancesGmshGrid3D.xGmshGrid3D.yGmshGrid3D.z
openMSHFile()openPOSFile()
- fipy.meshes.grid1D module
- fipy.meshes.grid2D module
- fipy.meshes.grid3D module
- fipy.meshes.mesh module
MeshMesh.VTKCellDataSetMesh.VTKFaceDataSetMesh.__add__()Mesh.__div__()Mesh.__getstate__()Mesh.__mul__()Mesh.__radd__()Mesh.__repr__()Mesh.__rmul__()Mesh.__setstate__()Mesh.__sub__()Mesh.__truediv__()Mesh.aspect2DMesh.cellCentersMesh.cellDistanceVectorsMesh.cellFaceIDsMesh.cellToFaceDistanceVectorsMesh.cellVolumesMesh.extentsMesh.exteriorFacesMesh.faceCentersMesh.facesBackMesh.facesBottomMesh.facesDownMesh.facesFrontMesh.facesLeftMesh.facesRightMesh.facesTopMesh.facesUpMesh.getNearestCell()Mesh.interiorFaceCellIDsMesh.interiorFaceIDsMesh.interiorFacesMesh.scaleMesh.scaledCellDistancesMesh.scaledCellToCellDistancesMesh.scaledCellVolumesMesh.scaledFaceAreasMesh.scaledFaceToCellDistancesMesh.xMesh.yMesh.z
MeshAdditionErrorMeshAdditionError.__cause__MeshAdditionError.__context__MeshAdditionError.__delattr__()MeshAdditionError.__getattribute__()MeshAdditionError.__reduce__()MeshAdditionError.__repr__()MeshAdditionError.__setattr__()MeshAdditionError.__setstate__()MeshAdditionError.__str__()MeshAdditionError.__suppress_context__MeshAdditionError.__traceback__MeshAdditionError.argsMeshAdditionError.with_traceback()
- fipy.meshes.mesh1D module
Mesh1DMesh1D.VTKCellDataSetMesh1D.VTKFaceDataSetMesh1D.__add__()Mesh1D.__div__()Mesh1D.__getstate__()Mesh1D.__mul__()Mesh1D.__radd__()Mesh1D.__repr__()Mesh1D.__rmul__()Mesh1D.__setstate__()Mesh1D.__sub__()Mesh1D.__truediv__()Mesh1D.aspect2DMesh1D.cellCentersMesh1D.cellDistanceVectorsMesh1D.cellFaceIDsMesh1D.cellToFaceDistanceVectorsMesh1D.cellVolumesMesh1D.extentsMesh1D.exteriorFacesMesh1D.faceCentersMesh1D.facesBackMesh1D.facesBottomMesh1D.facesDownMesh1D.facesFrontMesh1D.facesLeftMesh1D.facesRightMesh1D.facesTopMesh1D.facesUpMesh1D.getNearestCell()Mesh1D.interiorFaceCellIDsMesh1D.interiorFaceIDsMesh1D.interiorFacesMesh1D.scaleMesh1D.scaledCellDistancesMesh1D.scaledCellToCellDistancesMesh1D.scaledCellVolumesMesh1D.scaledFaceAreasMesh1D.scaledFaceToCellDistancesMesh1D.xMesh1D.yMesh1D.z
- fipy.meshes.mesh2D module
Mesh2DMesh2D.VTKCellDataSetMesh2D.VTKFaceDataSetMesh2D.__add__()Mesh2D.__div__()Mesh2D.__getstate__()Mesh2D.__mul__()Mesh2D.__radd__()Mesh2D.__repr__()Mesh2D.__rmul__()Mesh2D.__setstate__()Mesh2D.__sub__()Mesh2D.__truediv__()Mesh2D.aspect2DMesh2D.cellCentersMesh2D.cellDistanceVectorsMesh2D.cellFaceIDsMesh2D.cellToFaceDistanceVectorsMesh2D.cellVolumesMesh2D.extentsMesh2D.exteriorFacesMesh2D.extrude()Mesh2D.faceCentersMesh2D.facesBackMesh2D.facesBottomMesh2D.facesDownMesh2D.facesFrontMesh2D.facesLeftMesh2D.facesRightMesh2D.facesTopMesh2D.facesUpMesh2D.getNearestCell()Mesh2D.interiorFaceCellIDsMesh2D.interiorFaceIDsMesh2D.interiorFacesMesh2D.scaleMesh2D.scaledCellDistancesMesh2D.scaledCellToCellDistancesMesh2D.scaledCellVolumesMesh2D.scaledFaceAreasMesh2D.scaledFaceToCellDistancesMesh2D.xMesh2D.yMesh2D.z
- fipy.meshes.nonUniformGrid1D module
NonUniformGrid1DNonUniformGrid1D.VTKCellDataSetNonUniformGrid1D.VTKFaceDataSetNonUniformGrid1D.__add__()NonUniformGrid1D.__div__()NonUniformGrid1D.__getstate__()NonUniformGrid1D.__mul__()NonUniformGrid1D.__radd__()NonUniformGrid1D.__repr__()NonUniformGrid1D.__rmul__()NonUniformGrid1D.__setstate__()NonUniformGrid1D.__sub__()NonUniformGrid1D.__truediv__()NonUniformGrid1D.aspect2DNonUniformGrid1D.cellCentersNonUniformGrid1D.cellDistanceVectorsNonUniformGrid1D.cellFaceIDsNonUniformGrid1D.cellToFaceDistanceVectorsNonUniformGrid1D.cellVolumesNonUniformGrid1D.extentsNonUniformGrid1D.exteriorFacesNonUniformGrid1D.faceCentersNonUniformGrid1D.facesBackNonUniformGrid1D.facesBottomNonUniformGrid1D.facesDownNonUniformGrid1D.facesFrontNonUniformGrid1D.facesLeftNonUniformGrid1D.facesRightNonUniformGrid1D.facesTopNonUniformGrid1D.facesUpNonUniformGrid1D.getNearestCell()NonUniformGrid1D.interiorFaceCellIDsNonUniformGrid1D.interiorFaceIDsNonUniformGrid1D.interiorFacesNonUniformGrid1D.scaleNonUniformGrid1D.scaledCellDistancesNonUniformGrid1D.scaledCellToCellDistancesNonUniformGrid1D.scaledCellVolumesNonUniformGrid1D.scaledFaceAreasNonUniformGrid1D.scaledFaceToCellDistancesNonUniformGrid1D.xNonUniformGrid1D.yNonUniformGrid1D.z
- fipy.meshes.nonUniformGrid2D module
NonUniformGrid2DNonUniformGrid2D.VTKCellDataSetNonUniformGrid2D.VTKFaceDataSetNonUniformGrid2D.__add__()NonUniformGrid2D.__div__()NonUniformGrid2D.__getstate__()NonUniformGrid2D.__mul__()NonUniformGrid2D.__radd__()NonUniformGrid2D.__repr__()NonUniformGrid2D.__rmul__()NonUniformGrid2D.__setstate__()NonUniformGrid2D.__sub__()NonUniformGrid2D.__truediv__()NonUniformGrid2D.aspect2DNonUniformGrid2D.cellCentersNonUniformGrid2D.cellDistanceVectorsNonUniformGrid2D.cellFaceIDsNonUniformGrid2D.cellToFaceDistanceVectorsNonUniformGrid2D.cellVolumesNonUniformGrid2D.extentsNonUniformGrid2D.exteriorFacesNonUniformGrid2D.extrude()NonUniformGrid2D.faceCentersNonUniformGrid2D.facesBackNonUniformGrid2D.facesBottomNonUniformGrid2D.facesDownNonUniformGrid2D.facesFrontNonUniformGrid2D.facesLeftNonUniformGrid2D.facesRightNonUniformGrid2D.facesTopNonUniformGrid2D.facesUpNonUniformGrid2D.getNearestCell()NonUniformGrid2D.interiorFaceCellIDsNonUniformGrid2D.interiorFaceIDsNonUniformGrid2D.interiorFacesNonUniformGrid2D.scaleNonUniformGrid2D.scaledCellDistancesNonUniformGrid2D.scaledCellToCellDistancesNonUniformGrid2D.scaledCellVolumesNonUniformGrid2D.scaledFaceAreasNonUniformGrid2D.scaledFaceToCellDistancesNonUniformGrid2D.xNonUniformGrid2D.yNonUniformGrid2D.z
- fipy.meshes.nonUniformGrid3D module
NonUniformGrid3DNonUniformGrid3D.VTKCellDataSetNonUniformGrid3D.VTKFaceDataSetNonUniformGrid3D.__add__()NonUniformGrid3D.__div__()NonUniformGrid3D.__getstate__()NonUniformGrid3D.__mul__()NonUniformGrid3D.__radd__()NonUniformGrid3D.__repr__()NonUniformGrid3D.__rmul__()NonUniformGrid3D.__setstate__()NonUniformGrid3D.__sub__()NonUniformGrid3D.__truediv__()NonUniformGrid3D.aspect2DNonUniformGrid3D.cellCentersNonUniformGrid3D.cellDistanceVectorsNonUniformGrid3D.cellFaceIDsNonUniformGrid3D.cellToFaceDistanceVectorsNonUniformGrid3D.cellVolumesNonUniformGrid3D.extentsNonUniformGrid3D.exteriorFacesNonUniformGrid3D.faceCentersNonUniformGrid3D.facesBackNonUniformGrid3D.facesBottomNonUniformGrid3D.facesDownNonUniformGrid3D.facesFrontNonUniformGrid3D.facesLeftNonUniformGrid3D.facesRightNonUniformGrid3D.facesTopNonUniformGrid3D.facesUpNonUniformGrid3D.getNearestCell()NonUniformGrid3D.interiorFaceCellIDsNonUniformGrid3D.interiorFaceIDsNonUniformGrid3D.interiorFacesNonUniformGrid3D.scaleNonUniformGrid3D.scaledCellDistancesNonUniformGrid3D.scaledCellToCellDistancesNonUniformGrid3D.scaledCellVolumesNonUniformGrid3D.scaledFaceAreasNonUniformGrid3D.scaledFaceToCellDistancesNonUniformGrid3D.xNonUniformGrid3D.yNonUniformGrid3D.z
- fipy.meshes.periodicGrid1D module
PeriodicGrid1DPeriodicGrid1D.VTKCellDataSetPeriodicGrid1D.VTKFaceDataSetPeriodicGrid1D.__add__()PeriodicGrid1D.__div__()PeriodicGrid1D.__getstate__()PeriodicGrid1D.__mul__()PeriodicGrid1D.__radd__()PeriodicGrid1D.__repr__()PeriodicGrid1D.__rmul__()PeriodicGrid1D.__setstate__()PeriodicGrid1D.__sub__()PeriodicGrid1D.__truediv__()PeriodicGrid1D.aspect2DPeriodicGrid1D.cellCentersPeriodicGrid1D.cellDistanceVectorsPeriodicGrid1D.cellFaceIDsPeriodicGrid1D.cellToFaceDistanceVectorsPeriodicGrid1D.cellVolumesPeriodicGrid1D.extentsPeriodicGrid1D.exteriorFacesPeriodicGrid1D.faceCentersPeriodicGrid1D.facesBackPeriodicGrid1D.facesBottomPeriodicGrid1D.facesDownPeriodicGrid1D.facesFrontPeriodicGrid1D.facesLeftPeriodicGrid1D.facesRightPeriodicGrid1D.facesTopPeriodicGrid1D.facesUpPeriodicGrid1D.getNearestCell()PeriodicGrid1D.interiorFaceCellIDsPeriodicGrid1D.interiorFaceIDsPeriodicGrid1D.interiorFacesPeriodicGrid1D.scalePeriodicGrid1D.scaledCellDistancesPeriodicGrid1D.scaledCellToCellDistancesPeriodicGrid1D.scaledCellVolumesPeriodicGrid1D.scaledFaceAreasPeriodicGrid1D.scaledFaceToCellDistancesPeriodicGrid1D.xPeriodicGrid1D.yPeriodicGrid1D.z
- fipy.meshes.periodicGrid2D module
PeriodicGrid2DPeriodicGrid2D.VTKCellDataSetPeriodicGrid2D.VTKFaceDataSetPeriodicGrid2D.__add__()PeriodicGrid2D.__div__()PeriodicGrid2D.__getstate__()PeriodicGrid2D.__mul__()PeriodicGrid2D.__radd__()PeriodicGrid2D.__repr__()PeriodicGrid2D.__rmul__()PeriodicGrid2D.__setstate__()PeriodicGrid2D.__sub__()PeriodicGrid2D.__truediv__()PeriodicGrid2D.aspect2DPeriodicGrid2D.cellCentersPeriodicGrid2D.cellDistanceVectorsPeriodicGrid2D.cellFaceIDsPeriodicGrid2D.cellToFaceDistanceVectorsPeriodicGrid2D.cellVolumesPeriodicGrid2D.extentsPeriodicGrid2D.exteriorFacesPeriodicGrid2D.extrude()PeriodicGrid2D.faceCentersPeriodicGrid2D.facesBackPeriodicGrid2D.facesBottomPeriodicGrid2D.facesDownPeriodicGrid2D.facesFrontPeriodicGrid2D.facesLeftPeriodicGrid2D.facesRightPeriodicGrid2D.facesTopPeriodicGrid2D.facesUpPeriodicGrid2D.getNearestCell()PeriodicGrid2D.interiorFaceCellIDsPeriodicGrid2D.interiorFaceIDsPeriodicGrid2D.interiorFacesPeriodicGrid2D.scalePeriodicGrid2D.scaledCellDistancesPeriodicGrid2D.scaledCellToCellDistancesPeriodicGrid2D.scaledCellVolumesPeriodicGrid2D.scaledFaceAreasPeriodicGrid2D.scaledFaceToCellDistancesPeriodicGrid2D.xPeriodicGrid2D.yPeriodicGrid2D.z
PeriodicGrid2DLeftRightPeriodicGrid2DLeftRight.VTKCellDataSetPeriodicGrid2DLeftRight.VTKFaceDataSetPeriodicGrid2DLeftRight.__add__()PeriodicGrid2DLeftRight.__div__()PeriodicGrid2DLeftRight.__getstate__()PeriodicGrid2DLeftRight.__mul__()PeriodicGrid2DLeftRight.__radd__()PeriodicGrid2DLeftRight.__repr__()PeriodicGrid2DLeftRight.__rmul__()PeriodicGrid2DLeftRight.__setstate__()PeriodicGrid2DLeftRight.__sub__()PeriodicGrid2DLeftRight.__truediv__()PeriodicGrid2DLeftRight.aspect2DPeriodicGrid2DLeftRight.cellCentersPeriodicGrid2DLeftRight.cellDistanceVectorsPeriodicGrid2DLeftRight.cellFaceIDsPeriodicGrid2DLeftRight.cellToFaceDistanceVectorsPeriodicGrid2DLeftRight.cellVolumesPeriodicGrid2DLeftRight.extentsPeriodicGrid2DLeftRight.exteriorFacesPeriodicGrid2DLeftRight.extrude()PeriodicGrid2DLeftRight.faceCentersPeriodicGrid2DLeftRight.facesBackPeriodicGrid2DLeftRight.facesBottomPeriodicGrid2DLeftRight.facesDownPeriodicGrid2DLeftRight.facesFrontPeriodicGrid2DLeftRight.facesLeftPeriodicGrid2DLeftRight.facesRightPeriodicGrid2DLeftRight.facesTopPeriodicGrid2DLeftRight.facesUpPeriodicGrid2DLeftRight.getNearestCell()PeriodicGrid2DLeftRight.interiorFaceCellIDsPeriodicGrid2DLeftRight.interiorFaceIDsPeriodicGrid2DLeftRight.interiorFacesPeriodicGrid2DLeftRight.scalePeriodicGrid2DLeftRight.scaledCellDistancesPeriodicGrid2DLeftRight.scaledCellToCellDistancesPeriodicGrid2DLeftRight.scaledCellVolumesPeriodicGrid2DLeftRight.scaledFaceAreasPeriodicGrid2DLeftRight.scaledFaceToCellDistancesPeriodicGrid2DLeftRight.xPeriodicGrid2DLeftRight.yPeriodicGrid2DLeftRight.z
PeriodicGrid2DTopBottomPeriodicGrid2DTopBottom.VTKCellDataSetPeriodicGrid2DTopBottom.VTKFaceDataSetPeriodicGrid2DTopBottom.__add__()PeriodicGrid2DTopBottom.__div__()PeriodicGrid2DTopBottom.__getstate__()PeriodicGrid2DTopBottom.__mul__()PeriodicGrid2DTopBottom.__radd__()PeriodicGrid2DTopBottom.__repr__()PeriodicGrid2DTopBottom.__rmul__()PeriodicGrid2DTopBottom.__setstate__()PeriodicGrid2DTopBottom.__sub__()PeriodicGrid2DTopBottom.__truediv__()PeriodicGrid2DTopBottom.aspect2DPeriodicGrid2DTopBottom.cellCentersPeriodicGrid2DTopBottom.cellDistanceVectorsPeriodicGrid2DTopBottom.cellFaceIDsPeriodicGrid2DTopBottom.cellToFaceDistanceVectorsPeriodicGrid2DTopBottom.cellVolumesPeriodicGrid2DTopBottom.extentsPeriodicGrid2DTopBottom.exteriorFacesPeriodicGrid2DTopBottom.extrude()PeriodicGrid2DTopBottom.faceCentersPeriodicGrid2DTopBottom.facesBackPeriodicGrid2DTopBottom.facesBottomPeriodicGrid2DTopBottom.facesDownPeriodicGrid2DTopBottom.facesFrontPeriodicGrid2DTopBottom.facesLeftPeriodicGrid2DTopBottom.facesRightPeriodicGrid2DTopBottom.facesTopPeriodicGrid2DTopBottom.facesUpPeriodicGrid2DTopBottom.getNearestCell()PeriodicGrid2DTopBottom.interiorFaceCellIDsPeriodicGrid2DTopBottom.interiorFaceIDsPeriodicGrid2DTopBottom.interiorFacesPeriodicGrid2DTopBottom.scalePeriodicGrid2DTopBottom.scaledCellDistancesPeriodicGrid2DTopBottom.scaledCellToCellDistancesPeriodicGrid2DTopBottom.scaledCellVolumesPeriodicGrid2DTopBottom.scaledFaceAreasPeriodicGrid2DTopBottom.scaledFaceToCellDistancesPeriodicGrid2DTopBottom.xPeriodicGrid2DTopBottom.yPeriodicGrid2DTopBottom.z
- fipy.meshes.periodicGrid3D module
PeriodicGrid3DPeriodicGrid3D.VTKCellDataSetPeriodicGrid3D.VTKFaceDataSetPeriodicGrid3D.__add__()PeriodicGrid3D.__div__()PeriodicGrid3D.__getstate__()PeriodicGrid3D.__mul__()PeriodicGrid3D.__radd__()PeriodicGrid3D.__repr__()PeriodicGrid3D.__rmul__()PeriodicGrid3D.__setstate__()PeriodicGrid3D.__sub__()PeriodicGrid3D.__truediv__()PeriodicGrid3D.aspect2DPeriodicGrid3D.cellCentersPeriodicGrid3D.cellDistanceVectorsPeriodicGrid3D.cellFaceIDsPeriodicGrid3D.cellToFaceDistanceVectorsPeriodicGrid3D.cellVolumesPeriodicGrid3D.extentsPeriodicGrid3D.exteriorFacesPeriodicGrid3D.faceCentersPeriodicGrid3D.facesBackPeriodicGrid3D.facesBottomPeriodicGrid3D.facesDownPeriodicGrid3D.facesFrontPeriodicGrid3D.facesLeftPeriodicGrid3D.facesRightPeriodicGrid3D.facesTopPeriodicGrid3D.facesUpPeriodicGrid3D.getNearestCell()PeriodicGrid3D.interiorFaceCellIDsPeriodicGrid3D.interiorFaceIDsPeriodicGrid3D.interiorFacesPeriodicGrid3D.scalePeriodicGrid3D.scaledCellDistancesPeriodicGrid3D.scaledCellToCellDistancesPeriodicGrid3D.scaledCellVolumesPeriodicGrid3D.scaledFaceAreasPeriodicGrid3D.scaledFaceToCellDistancesPeriodicGrid3D.xPeriodicGrid3D.yPeriodicGrid3D.z
PeriodicGrid3DFrontBackPeriodicGrid3DFrontBack.VTKCellDataSetPeriodicGrid3DFrontBack.VTKFaceDataSetPeriodicGrid3DFrontBack.__add__()PeriodicGrid3DFrontBack.__div__()PeriodicGrid3DFrontBack.__getstate__()PeriodicGrid3DFrontBack.__mul__()PeriodicGrid3DFrontBack.__radd__()PeriodicGrid3DFrontBack.__repr__()PeriodicGrid3DFrontBack.__rmul__()PeriodicGrid3DFrontBack.__setstate__()PeriodicGrid3DFrontBack.__sub__()PeriodicGrid3DFrontBack.__truediv__()PeriodicGrid3DFrontBack.aspect2DPeriodicGrid3DFrontBack.cellCentersPeriodicGrid3DFrontBack.cellDistanceVectorsPeriodicGrid3DFrontBack.cellFaceIDsPeriodicGrid3DFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DFrontBack.cellVolumesPeriodicGrid3DFrontBack.extentsPeriodicGrid3DFrontBack.exteriorFacesPeriodicGrid3DFrontBack.faceCentersPeriodicGrid3DFrontBack.facesBackPeriodicGrid3DFrontBack.facesBottomPeriodicGrid3DFrontBack.facesDownPeriodicGrid3DFrontBack.facesFrontPeriodicGrid3DFrontBack.facesLeftPeriodicGrid3DFrontBack.facesRightPeriodicGrid3DFrontBack.facesTopPeriodicGrid3DFrontBack.facesUpPeriodicGrid3DFrontBack.getNearestCell()PeriodicGrid3DFrontBack.interiorFaceCellIDsPeriodicGrid3DFrontBack.interiorFaceIDsPeriodicGrid3DFrontBack.interiorFacesPeriodicGrid3DFrontBack.scalePeriodicGrid3DFrontBack.scaledCellDistancesPeriodicGrid3DFrontBack.scaledCellToCellDistancesPeriodicGrid3DFrontBack.scaledCellVolumesPeriodicGrid3DFrontBack.scaledFaceAreasPeriodicGrid3DFrontBack.scaledFaceToCellDistancesPeriodicGrid3DFrontBack.xPeriodicGrid3DFrontBack.yPeriodicGrid3DFrontBack.z
PeriodicGrid3DLeftRightPeriodicGrid3DLeftRight.VTKCellDataSetPeriodicGrid3DLeftRight.VTKFaceDataSetPeriodicGrid3DLeftRight.__add__()PeriodicGrid3DLeftRight.__div__()PeriodicGrid3DLeftRight.__getstate__()PeriodicGrid3DLeftRight.__mul__()PeriodicGrid3DLeftRight.__radd__()PeriodicGrid3DLeftRight.__repr__()PeriodicGrid3DLeftRight.__rmul__()PeriodicGrid3DLeftRight.__setstate__()PeriodicGrid3DLeftRight.__sub__()PeriodicGrid3DLeftRight.__truediv__()PeriodicGrid3DLeftRight.aspect2DPeriodicGrid3DLeftRight.cellCentersPeriodicGrid3DLeftRight.cellDistanceVectorsPeriodicGrid3DLeftRight.cellFaceIDsPeriodicGrid3DLeftRight.cellToFaceDistanceVectorsPeriodicGrid3DLeftRight.cellVolumesPeriodicGrid3DLeftRight.extentsPeriodicGrid3DLeftRight.exteriorFacesPeriodicGrid3DLeftRight.faceCentersPeriodicGrid3DLeftRight.facesBackPeriodicGrid3DLeftRight.facesBottomPeriodicGrid3DLeftRight.facesDownPeriodicGrid3DLeftRight.facesFrontPeriodicGrid3DLeftRight.facesLeftPeriodicGrid3DLeftRight.facesRightPeriodicGrid3DLeftRight.facesTopPeriodicGrid3DLeftRight.facesUpPeriodicGrid3DLeftRight.getNearestCell()PeriodicGrid3DLeftRight.interiorFaceCellIDsPeriodicGrid3DLeftRight.interiorFaceIDsPeriodicGrid3DLeftRight.interiorFacesPeriodicGrid3DLeftRight.scalePeriodicGrid3DLeftRight.scaledCellDistancesPeriodicGrid3DLeftRight.scaledCellToCellDistancesPeriodicGrid3DLeftRight.scaledCellVolumesPeriodicGrid3DLeftRight.scaledFaceAreasPeriodicGrid3DLeftRight.scaledFaceToCellDistancesPeriodicGrid3DLeftRight.xPeriodicGrid3DLeftRight.yPeriodicGrid3DLeftRight.z
PeriodicGrid3DLeftRightFrontBackPeriodicGrid3DLeftRightFrontBack.VTKCellDataSetPeriodicGrid3DLeftRightFrontBack.VTKFaceDataSetPeriodicGrid3DLeftRightFrontBack.__add__()PeriodicGrid3DLeftRightFrontBack.__div__()PeriodicGrid3DLeftRightFrontBack.__getstate__()PeriodicGrid3DLeftRightFrontBack.__mul__()PeriodicGrid3DLeftRightFrontBack.__radd__()PeriodicGrid3DLeftRightFrontBack.__repr__()PeriodicGrid3DLeftRightFrontBack.__rmul__()PeriodicGrid3DLeftRightFrontBack.__setstate__()PeriodicGrid3DLeftRightFrontBack.__sub__()PeriodicGrid3DLeftRightFrontBack.__truediv__()PeriodicGrid3DLeftRightFrontBack.aspect2DPeriodicGrid3DLeftRightFrontBack.cellCentersPeriodicGrid3DLeftRightFrontBack.cellDistanceVectorsPeriodicGrid3DLeftRightFrontBack.cellFaceIDsPeriodicGrid3DLeftRightFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DLeftRightFrontBack.cellVolumesPeriodicGrid3DLeftRightFrontBack.extentsPeriodicGrid3DLeftRightFrontBack.exteriorFacesPeriodicGrid3DLeftRightFrontBack.faceCentersPeriodicGrid3DLeftRightFrontBack.facesBackPeriodicGrid3DLeftRightFrontBack.facesBottomPeriodicGrid3DLeftRightFrontBack.facesDownPeriodicGrid3DLeftRightFrontBack.facesFrontPeriodicGrid3DLeftRightFrontBack.facesLeftPeriodicGrid3DLeftRightFrontBack.facesRightPeriodicGrid3DLeftRightFrontBack.facesTopPeriodicGrid3DLeftRightFrontBack.facesUpPeriodicGrid3DLeftRightFrontBack.getNearestCell()PeriodicGrid3DLeftRightFrontBack.interiorFaceCellIDsPeriodicGrid3DLeftRightFrontBack.interiorFaceIDsPeriodicGrid3DLeftRightFrontBack.interiorFacesPeriodicGrid3DLeftRightFrontBack.scalePeriodicGrid3DLeftRightFrontBack.scaledCellDistancesPeriodicGrid3DLeftRightFrontBack.scaledCellToCellDistancesPeriodicGrid3DLeftRightFrontBack.scaledCellVolumesPeriodicGrid3DLeftRightFrontBack.scaledFaceAreasPeriodicGrid3DLeftRightFrontBack.scaledFaceToCellDistancesPeriodicGrid3DLeftRightFrontBack.xPeriodicGrid3DLeftRightFrontBack.yPeriodicGrid3DLeftRightFrontBack.z
PeriodicGrid3DLeftRightTopBottomPeriodicGrid3DLeftRightTopBottom.VTKCellDataSetPeriodicGrid3DLeftRightTopBottom.VTKFaceDataSetPeriodicGrid3DLeftRightTopBottom.__add__()PeriodicGrid3DLeftRightTopBottom.__div__()PeriodicGrid3DLeftRightTopBottom.__getstate__()PeriodicGrid3DLeftRightTopBottom.__mul__()PeriodicGrid3DLeftRightTopBottom.__radd__()PeriodicGrid3DLeftRightTopBottom.__repr__()PeriodicGrid3DLeftRightTopBottom.__rmul__()PeriodicGrid3DLeftRightTopBottom.__setstate__()PeriodicGrid3DLeftRightTopBottom.__sub__()PeriodicGrid3DLeftRightTopBottom.__truediv__()PeriodicGrid3DLeftRightTopBottom.aspect2DPeriodicGrid3DLeftRightTopBottom.cellCentersPeriodicGrid3DLeftRightTopBottom.cellDistanceVectorsPeriodicGrid3DLeftRightTopBottom.cellFaceIDsPeriodicGrid3DLeftRightTopBottom.cellToFaceDistanceVectorsPeriodicGrid3DLeftRightTopBottom.cellVolumesPeriodicGrid3DLeftRightTopBottom.extentsPeriodicGrid3DLeftRightTopBottom.exteriorFacesPeriodicGrid3DLeftRightTopBottom.faceCentersPeriodicGrid3DLeftRightTopBottom.facesBackPeriodicGrid3DLeftRightTopBottom.facesBottomPeriodicGrid3DLeftRightTopBottom.facesDownPeriodicGrid3DLeftRightTopBottom.facesFrontPeriodicGrid3DLeftRightTopBottom.facesLeftPeriodicGrid3DLeftRightTopBottom.facesRightPeriodicGrid3DLeftRightTopBottom.facesTopPeriodicGrid3DLeftRightTopBottom.facesUpPeriodicGrid3DLeftRightTopBottom.getNearestCell()PeriodicGrid3DLeftRightTopBottom.interiorFaceCellIDsPeriodicGrid3DLeftRightTopBottom.interiorFaceIDsPeriodicGrid3DLeftRightTopBottom.interiorFacesPeriodicGrid3DLeftRightTopBottom.scalePeriodicGrid3DLeftRightTopBottom.scaledCellDistancesPeriodicGrid3DLeftRightTopBottom.scaledCellToCellDistancesPeriodicGrid3DLeftRightTopBottom.scaledCellVolumesPeriodicGrid3DLeftRightTopBottom.scaledFaceAreasPeriodicGrid3DLeftRightTopBottom.scaledFaceToCellDistancesPeriodicGrid3DLeftRightTopBottom.xPeriodicGrid3DLeftRightTopBottom.yPeriodicGrid3DLeftRightTopBottom.z
PeriodicGrid3DTopBottomPeriodicGrid3DTopBottom.VTKCellDataSetPeriodicGrid3DTopBottom.VTKFaceDataSetPeriodicGrid3DTopBottom.__add__()PeriodicGrid3DTopBottom.__div__()PeriodicGrid3DTopBottom.__getstate__()PeriodicGrid3DTopBottom.__mul__()PeriodicGrid3DTopBottom.__radd__()PeriodicGrid3DTopBottom.__repr__()PeriodicGrid3DTopBottom.__rmul__()PeriodicGrid3DTopBottom.__setstate__()PeriodicGrid3DTopBottom.__sub__()PeriodicGrid3DTopBottom.__truediv__()PeriodicGrid3DTopBottom.aspect2DPeriodicGrid3DTopBottom.cellCentersPeriodicGrid3DTopBottom.cellDistanceVectorsPeriodicGrid3DTopBottom.cellFaceIDsPeriodicGrid3DTopBottom.cellToFaceDistanceVectorsPeriodicGrid3DTopBottom.cellVolumesPeriodicGrid3DTopBottom.extentsPeriodicGrid3DTopBottom.exteriorFacesPeriodicGrid3DTopBottom.faceCentersPeriodicGrid3DTopBottom.facesBackPeriodicGrid3DTopBottom.facesBottomPeriodicGrid3DTopBottom.facesDownPeriodicGrid3DTopBottom.facesFrontPeriodicGrid3DTopBottom.facesLeftPeriodicGrid3DTopBottom.facesRightPeriodicGrid3DTopBottom.facesTopPeriodicGrid3DTopBottom.facesUpPeriodicGrid3DTopBottom.getNearestCell()PeriodicGrid3DTopBottom.interiorFaceCellIDsPeriodicGrid3DTopBottom.interiorFaceIDsPeriodicGrid3DTopBottom.interiorFacesPeriodicGrid3DTopBottom.scalePeriodicGrid3DTopBottom.scaledCellDistancesPeriodicGrid3DTopBottom.scaledCellToCellDistancesPeriodicGrid3DTopBottom.scaledCellVolumesPeriodicGrid3DTopBottom.scaledFaceAreasPeriodicGrid3DTopBottom.scaledFaceToCellDistancesPeriodicGrid3DTopBottom.xPeriodicGrid3DTopBottom.yPeriodicGrid3DTopBottom.z
PeriodicGrid3DTopBottomFrontBackPeriodicGrid3DTopBottomFrontBack.VTKCellDataSetPeriodicGrid3DTopBottomFrontBack.VTKFaceDataSetPeriodicGrid3DTopBottomFrontBack.__add__()PeriodicGrid3DTopBottomFrontBack.__div__()PeriodicGrid3DTopBottomFrontBack.__getstate__()PeriodicGrid3DTopBottomFrontBack.__mul__()PeriodicGrid3DTopBottomFrontBack.__radd__()PeriodicGrid3DTopBottomFrontBack.__repr__()PeriodicGrid3DTopBottomFrontBack.__rmul__()PeriodicGrid3DTopBottomFrontBack.__setstate__()PeriodicGrid3DTopBottomFrontBack.__sub__()PeriodicGrid3DTopBottomFrontBack.__truediv__()PeriodicGrid3DTopBottomFrontBack.aspect2DPeriodicGrid3DTopBottomFrontBack.cellCentersPeriodicGrid3DTopBottomFrontBack.cellDistanceVectorsPeriodicGrid3DTopBottomFrontBack.cellFaceIDsPeriodicGrid3DTopBottomFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DTopBottomFrontBack.cellVolumesPeriodicGrid3DTopBottomFrontBack.extentsPeriodicGrid3DTopBottomFrontBack.exteriorFacesPeriodicGrid3DTopBottomFrontBack.faceCentersPeriodicGrid3DTopBottomFrontBack.facesBackPeriodicGrid3DTopBottomFrontBack.facesBottomPeriodicGrid3DTopBottomFrontBack.facesDownPeriodicGrid3DTopBottomFrontBack.facesFrontPeriodicGrid3DTopBottomFrontBack.facesLeftPeriodicGrid3DTopBottomFrontBack.facesRightPeriodicGrid3DTopBottomFrontBack.facesTopPeriodicGrid3DTopBottomFrontBack.facesUpPeriodicGrid3DTopBottomFrontBack.getNearestCell()PeriodicGrid3DTopBottomFrontBack.interiorFaceCellIDsPeriodicGrid3DTopBottomFrontBack.interiorFaceIDsPeriodicGrid3DTopBottomFrontBack.interiorFacesPeriodicGrid3DTopBottomFrontBack.scalePeriodicGrid3DTopBottomFrontBack.scaledCellDistancesPeriodicGrid3DTopBottomFrontBack.scaledCellToCellDistancesPeriodicGrid3DTopBottomFrontBack.scaledCellVolumesPeriodicGrid3DTopBottomFrontBack.scaledFaceAreasPeriodicGrid3DTopBottomFrontBack.scaledFaceToCellDistancesPeriodicGrid3DTopBottomFrontBack.xPeriodicGrid3DTopBottomFrontBack.yPeriodicGrid3DTopBottomFrontBack.z
- fipy.meshes.skewedGrid2D module
SkewedGrid2DSkewedGrid2D.VTKCellDataSetSkewedGrid2D.VTKFaceDataSetSkewedGrid2D.__add__()SkewedGrid2D.__div__()SkewedGrid2D.__getstate__()SkewedGrid2D.__mul__()SkewedGrid2D.__radd__()SkewedGrid2D.__repr__()SkewedGrid2D.__rmul__()SkewedGrid2D.__setstate__()SkewedGrid2D.__sub__()SkewedGrid2D.__truediv__()SkewedGrid2D.aspect2DSkewedGrid2D.cellCentersSkewedGrid2D.cellDistanceVectorsSkewedGrid2D.cellFaceIDsSkewedGrid2D.cellToFaceDistanceVectorsSkewedGrid2D.cellVolumesSkewedGrid2D.extentsSkewedGrid2D.exteriorFacesSkewedGrid2D.extrude()SkewedGrid2D.faceCentersSkewedGrid2D.facesBackSkewedGrid2D.facesBottomSkewedGrid2D.facesDownSkewedGrid2D.facesFrontSkewedGrid2D.facesLeftSkewedGrid2D.facesRightSkewedGrid2D.facesTopSkewedGrid2D.facesUpSkewedGrid2D.getNearestCell()SkewedGrid2D.interiorFaceCellIDsSkewedGrid2D.interiorFaceIDsSkewedGrid2D.interiorFacesSkewedGrid2D.physicalShapeSkewedGrid2D.scaleSkewedGrid2D.scaledCellDistancesSkewedGrid2D.scaledCellToCellDistancesSkewedGrid2D.scaledCellVolumesSkewedGrid2D.scaledFaceAreasSkewedGrid2D.scaledFaceToCellDistancesSkewedGrid2D.shapeSkewedGrid2D.xSkewedGrid2D.ySkewedGrid2D.z
- fipy.meshes.sphericalNonUniformGrid1D module
SphericalNonUniformGrid1DSphericalNonUniformGrid1D.VTKCellDataSetSphericalNonUniformGrid1D.VTKFaceDataSetSphericalNonUniformGrid1D.__add__()SphericalNonUniformGrid1D.__div__()SphericalNonUniformGrid1D.__getstate__()SphericalNonUniformGrid1D.__mul__()SphericalNonUniformGrid1D.__radd__()SphericalNonUniformGrid1D.__repr__()SphericalNonUniformGrid1D.__rmul__()SphericalNonUniformGrid1D.__setstate__()SphericalNonUniformGrid1D.__sub__()SphericalNonUniformGrid1D.__truediv__()SphericalNonUniformGrid1D.aspect2DSphericalNonUniformGrid1D.cellCentersSphericalNonUniformGrid1D.cellDistanceVectorsSphericalNonUniformGrid1D.cellFaceIDsSphericalNonUniformGrid1D.cellToFaceDistanceVectorsSphericalNonUniformGrid1D.cellVolumesSphericalNonUniformGrid1D.extentsSphericalNonUniformGrid1D.exteriorFacesSphericalNonUniformGrid1D.faceCentersSphericalNonUniformGrid1D.facesBackSphericalNonUniformGrid1D.facesBottomSphericalNonUniformGrid1D.facesDownSphericalNonUniformGrid1D.facesFrontSphericalNonUniformGrid1D.facesLeftSphericalNonUniformGrid1D.facesRightSphericalNonUniformGrid1D.facesTopSphericalNonUniformGrid1D.facesUpSphericalNonUniformGrid1D.getNearestCell()SphericalNonUniformGrid1D.interiorFaceCellIDsSphericalNonUniformGrid1D.interiorFaceIDsSphericalNonUniformGrid1D.interiorFacesSphericalNonUniformGrid1D.scaleSphericalNonUniformGrid1D.scaledCellDistancesSphericalNonUniformGrid1D.scaledCellToCellDistancesSphericalNonUniformGrid1D.scaledCellVolumesSphericalNonUniformGrid1D.scaledFaceAreasSphericalNonUniformGrid1D.scaledFaceToCellDistancesSphericalNonUniformGrid1D.xSphericalNonUniformGrid1D.ySphericalNonUniformGrid1D.z
- fipy.meshes.sphericalUniformGrid1D module
SphericalUniformGrid1DSphericalUniformGrid1D.VTKCellDataSetSphericalUniformGrid1D.VTKFaceDataSetSphericalUniformGrid1D.__add__()SphericalUniformGrid1D.__div__()SphericalUniformGrid1D.__getstate__()SphericalUniformGrid1D.__mul__()SphericalUniformGrid1D.__radd__()SphericalUniformGrid1D.__repr__()SphericalUniformGrid1D.__rmul__()SphericalUniformGrid1D.__setstate__()SphericalUniformGrid1D.__sub__()SphericalUniformGrid1D.__truediv__()SphericalUniformGrid1D.aspect2DSphericalUniformGrid1D.cellCentersSphericalUniformGrid1D.cellDistanceVectorsSphericalUniformGrid1D.cellFaceIDsSphericalUniformGrid1D.cellToFaceDistanceVectorsSphericalUniformGrid1D.cellVolumesSphericalUniformGrid1D.extentsSphericalUniformGrid1D.exteriorFacesSphericalUniformGrid1D.faceCellIDsSphericalUniformGrid1D.faceCentersSphericalUniformGrid1D.faceNormalsSphericalUniformGrid1D.facesBackSphericalUniformGrid1D.facesBottomSphericalUniformGrid1D.facesDownSphericalUniformGrid1D.facesFrontSphericalUniformGrid1D.facesLeftSphericalUniformGrid1D.facesRightSphericalUniformGrid1D.facesTopSphericalUniformGrid1D.facesUpSphericalUniformGrid1D.getNearestCell()SphericalUniformGrid1D.interiorFaceCellIDsSphericalUniformGrid1D.interiorFaceIDsSphericalUniformGrid1D.interiorFacesSphericalUniformGrid1D.scaleSphericalUniformGrid1D.scaledCellDistancesSphericalUniformGrid1D.scaledCellToCellDistancesSphericalUniformGrid1D.scaledCellVolumesSphericalUniformGrid1D.scaledFaceAreasSphericalUniformGrid1D.scaledFaceToCellDistancesSphericalUniformGrid1D.vertexCoordsSphericalUniformGrid1D.xSphericalUniformGrid1D.ySphericalUniformGrid1D.z
- fipy.meshes.test module
- fipy.meshes.tri2D module
Tri2DTri2D.VTKCellDataSetTri2D.VTKFaceDataSetTri2D.__add__()Tri2D.__div__()Tri2D.__getstate__()Tri2D.__mul__()Tri2D.__radd__()Tri2D.__repr__()Tri2D.__rmul__()Tri2D.__setstate__()Tri2D.__sub__()Tri2D.__truediv__()Tri2D.aspect2DTri2D.cellCentersTri2D.cellDistanceVectorsTri2D.cellFaceIDsTri2D.cellToFaceDistanceVectorsTri2D.cellVolumesTri2D.extentsTri2D.exteriorFacesTri2D.extrude()Tri2D.faceCentersTri2D.facesBackTri2D.facesBottomTri2D.facesDownTri2D.facesFrontTri2D.facesLeftTri2D.facesRightTri2D.facesTopTri2D.facesUpTri2D.getNearestCell()Tri2D.interiorFaceCellIDsTri2D.interiorFaceIDsTri2D.interiorFacesTri2D.physicalShapeTri2D.scaleTri2D.scaledCellDistancesTri2D.scaledCellToCellDistancesTri2D.scaledCellVolumesTri2D.scaledFaceAreasTri2D.scaledFaceToCellDistancesTri2D.shapeTri2D.xTri2D.yTri2D.z
- fipy.meshes.uniformGrid module
UniformGridUniformGrid.VTKCellDataSetUniformGrid.VTKFaceDataSetUniformGrid.__add__()UniformGrid.__div__()UniformGrid.__getstate__()UniformGrid.__mul__()UniformGrid.__radd__()UniformGrid.__repr__()UniformGrid.__rmul__()UniformGrid.__setstate__()UniformGrid.__sub__()UniformGrid.__truediv__()UniformGrid.aspect2DUniformGrid.cellCentersUniformGrid.cellDistanceVectorsUniformGrid.cellFaceIDsUniformGrid.cellToFaceDistanceVectorsUniformGrid.cellVolumesUniformGrid.extentsUniformGrid.exteriorFacesUniformGrid.faceCentersUniformGrid.facesBackUniformGrid.facesBottomUniformGrid.facesDownUniformGrid.facesFrontUniformGrid.facesLeftUniformGrid.facesRightUniformGrid.facesTopUniformGrid.facesUpUniformGrid.getNearestCell()UniformGrid.interiorFaceCellIDsUniformGrid.interiorFaceIDsUniformGrid.interiorFacesUniformGrid.scaleUniformGrid.scaledCellDistancesUniformGrid.scaledCellToCellDistancesUniformGrid.scaledCellVolumesUniformGrid.scaledFaceAreasUniformGrid.scaledFaceToCellDistancesUniformGrid.xUniformGrid.yUniformGrid.z
- fipy.meshes.uniformGrid1D module
UniformGrid1DUniformGrid1D.VTKCellDataSetUniformGrid1D.VTKFaceDataSetUniformGrid1D.__add__()UniformGrid1D.__div__()UniformGrid1D.__getstate__()UniformGrid1D.__mul__()UniformGrid1D.__radd__()UniformGrid1D.__repr__()UniformGrid1D.__rmul__()UniformGrid1D.__setstate__()UniformGrid1D.__sub__()UniformGrid1D.__truediv__()UniformGrid1D.aspect2DUniformGrid1D.cellCentersUniformGrid1D.cellDistanceVectorsUniformGrid1D.cellFaceIDsUniformGrid1D.cellToFaceDistanceVectorsUniformGrid1D.cellVolumesUniformGrid1D.extentsUniformGrid1D.exteriorFacesUniformGrid1D.faceCellIDsUniformGrid1D.faceCentersUniformGrid1D.faceNormalsUniformGrid1D.facesBackUniformGrid1D.facesBottomUniformGrid1D.facesDownUniformGrid1D.facesFrontUniformGrid1D.facesLeftUniformGrid1D.facesRightUniformGrid1D.facesTopUniformGrid1D.facesUpUniformGrid1D.getNearestCell()UniformGrid1D.interiorFaceCellIDsUniformGrid1D.interiorFaceIDsUniformGrid1D.interiorFacesUniformGrid1D.scaleUniformGrid1D.scaledCellDistancesUniformGrid1D.scaledCellToCellDistancesUniformGrid1D.scaledCellVolumesUniformGrid1D.scaledFaceAreasUniformGrid1D.scaledFaceToCellDistancesUniformGrid1D.vertexCoordsUniformGrid1D.xUniformGrid1D.yUniformGrid1D.z
- fipy.meshes.uniformGrid2D module
UniformGrid2DUniformGrid2D.VTKCellDataSetUniformGrid2D.VTKFaceDataSetUniformGrid2D.__add__()UniformGrid2D.__div__()UniformGrid2D.__getstate__()UniformGrid2D.__mul__()UniformGrid2D.__radd__()UniformGrid2D.__repr__()UniformGrid2D.__rmul__()UniformGrid2D.__setstate__()UniformGrid2D.__sub__()UniformGrid2D.__truediv__()UniformGrid2D.aspect2DUniformGrid2D.cellCentersUniformGrid2D.cellDistanceVectorsUniformGrid2D.cellFaceIDsUniformGrid2D.cellToFaceDistanceVectorsUniformGrid2D.cellVolumesUniformGrid2D.extentsUniformGrid2D.exteriorFacesUniformGrid2D.faceCellIDsUniformGrid2D.faceCentersUniformGrid2D.faceNormalsUniformGrid2D.faceVertexIDsUniformGrid2D.facesBackUniformGrid2D.facesBottomUniformGrid2D.facesDownUniformGrid2D.facesFrontUniformGrid2D.facesLeftUniformGrid2D.facesRightUniformGrid2D.facesTopUniformGrid2D.facesUpUniformGrid2D.getNearestCell()UniformGrid2D.interiorFaceCellIDsUniformGrid2D.interiorFaceIDsUniformGrid2D.interiorFacesUniformGrid2D.scaleUniformGrid2D.scaledCellDistancesUniformGrid2D.scaledCellToCellDistancesUniformGrid2D.scaledCellVolumesUniformGrid2D.scaledFaceAreasUniformGrid2D.scaledFaceToCellDistancesUniformGrid2D.vertexCoordsUniformGrid2D.xUniformGrid2D.yUniformGrid2D.z
- fipy.meshes.uniformGrid3D module
UniformGrid3DUniformGrid3D.VTKCellDataSetUniformGrid3D.VTKFaceDataSetUniformGrid3D.__add__()UniformGrid3D.__div__()UniformGrid3D.__getstate__()UniformGrid3D.__mul__()UniformGrid3D.__radd__()UniformGrid3D.__repr__()UniformGrid3D.__rmul__()UniformGrid3D.__setstate__()UniformGrid3D.__sub__()UniformGrid3D.__truediv__()UniformGrid3D.aspect2DUniformGrid3D.cellCentersUniformGrid3D.cellDistanceVectorsUniformGrid3D.cellFaceIDsUniformGrid3D.cellToFaceDistanceVectorsUniformGrid3D.cellVolumesUniformGrid3D.extentsUniformGrid3D.exteriorFacesUniformGrid3D.faceCellIDsUniformGrid3D.faceCentersUniformGrid3D.faceNormalsUniformGrid3D.faceVertexIDsUniformGrid3D.facesBackUniformGrid3D.facesBottomUniformGrid3D.facesDownUniformGrid3D.facesFrontUniformGrid3D.facesLeftUniformGrid3D.facesRightUniformGrid3D.facesTopUniformGrid3D.facesUpUniformGrid3D.getNearestCell()UniformGrid3D.interiorFaceCellIDsUniformGrid3D.interiorFaceIDsUniformGrid3D.interiorFacesUniformGrid3D.scaleUniformGrid3D.scaledCellDistancesUniformGrid3D.scaledCellToCellDistancesUniformGrid3D.scaledCellVolumesUniformGrid3D.scaledFaceAreasUniformGrid3D.scaledFaceToCellDistancesUniformGrid3D.vertexCoordsUniformGrid3D.xUniformGrid3D.yUniformGrid3D.z
- Module contents
CylindricalGrid1D()CylindricalGrid2D()Gmsh2DGmsh2D.VTKCellDataSetGmsh2D.VTKFaceDataSetGmsh2D.__add__()Gmsh2D.__div__()Gmsh2D.__getstate__()Gmsh2D.__mul__()Gmsh2D.__radd__()Gmsh2D.__repr__()Gmsh2D.__rmul__()Gmsh2D.__setstate__()Gmsh2D.__sub__()Gmsh2D.__truediv__()Gmsh2D.aspect2DGmsh2D.cellCentersGmsh2D.cellDistanceVectorsGmsh2D.cellFaceIDsGmsh2D.cellToFaceDistanceVectorsGmsh2D.cellVolumesGmsh2D.extentsGmsh2D.exteriorFacesGmsh2D.extrude()Gmsh2D.faceCentersGmsh2D.facesBackGmsh2D.facesBottomGmsh2D.facesDownGmsh2D.facesFrontGmsh2D.facesLeftGmsh2D.facesRightGmsh2D.facesTopGmsh2D.facesUpGmsh2D.getNearestCell()Gmsh2D.interiorFaceCellIDsGmsh2D.interiorFaceIDsGmsh2D.interiorFacesGmsh2D.scaleGmsh2D.scaledCellDistancesGmsh2D.scaledCellToCellDistancesGmsh2D.scaledCellVolumesGmsh2D.scaledFaceAreasGmsh2D.scaledFaceToCellDistancesGmsh2D.xGmsh2D.yGmsh2D.z
Gmsh2DIn3DSpaceGmsh2DIn3DSpace.VTKCellDataSetGmsh2DIn3DSpace.VTKFaceDataSetGmsh2DIn3DSpace.__add__()Gmsh2DIn3DSpace.__div__()Gmsh2DIn3DSpace.__getstate__()Gmsh2DIn3DSpace.__mul__()Gmsh2DIn3DSpace.__radd__()Gmsh2DIn3DSpace.__repr__()Gmsh2DIn3DSpace.__rmul__()Gmsh2DIn3DSpace.__setstate__()Gmsh2DIn3DSpace.__sub__()Gmsh2DIn3DSpace.__truediv__()Gmsh2DIn3DSpace.aspect2DGmsh2DIn3DSpace.cellCentersGmsh2DIn3DSpace.cellDistanceVectorsGmsh2DIn3DSpace.cellFaceIDsGmsh2DIn3DSpace.cellToFaceDistanceVectorsGmsh2DIn3DSpace.cellVolumesGmsh2DIn3DSpace.extentsGmsh2DIn3DSpace.exteriorFacesGmsh2DIn3DSpace.extrude()Gmsh2DIn3DSpace.faceCentersGmsh2DIn3DSpace.facesBackGmsh2DIn3DSpace.facesBottomGmsh2DIn3DSpace.facesDownGmsh2DIn3DSpace.facesFrontGmsh2DIn3DSpace.facesLeftGmsh2DIn3DSpace.facesRightGmsh2DIn3DSpace.facesTopGmsh2DIn3DSpace.facesUpGmsh2DIn3DSpace.getNearestCell()Gmsh2DIn3DSpace.interiorFaceCellIDsGmsh2DIn3DSpace.interiorFaceIDsGmsh2DIn3DSpace.interiorFacesGmsh2DIn3DSpace.scaleGmsh2DIn3DSpace.scaledCellDistancesGmsh2DIn3DSpace.scaledCellToCellDistancesGmsh2DIn3DSpace.scaledCellVolumesGmsh2DIn3DSpace.scaledFaceAreasGmsh2DIn3DSpace.scaledFaceToCellDistancesGmsh2DIn3DSpace.xGmsh2DIn3DSpace.yGmsh2DIn3DSpace.z
Gmsh3DGmsh3D.VTKCellDataSetGmsh3D.VTKFaceDataSetGmsh3D.__add__()Gmsh3D.__div__()Gmsh3D.__getstate__()Gmsh3D.__mul__()Gmsh3D.__radd__()Gmsh3D.__repr__()Gmsh3D.__rmul__()Gmsh3D.__setstate__()Gmsh3D.__sub__()Gmsh3D.__truediv__()Gmsh3D.aspect2DGmsh3D.cellCentersGmsh3D.cellDistanceVectorsGmsh3D.cellFaceIDsGmsh3D.cellToFaceDistanceVectorsGmsh3D.cellVolumesGmsh3D.extentsGmsh3D.exteriorFacesGmsh3D.faceCentersGmsh3D.facesBackGmsh3D.facesBottomGmsh3D.facesDownGmsh3D.facesFrontGmsh3D.facesLeftGmsh3D.facesRightGmsh3D.facesTopGmsh3D.facesUpGmsh3D.getNearestCell()Gmsh3D.interiorFaceCellIDsGmsh3D.interiorFaceIDsGmsh3D.interiorFacesGmsh3D.scaleGmsh3D.scaledCellDistancesGmsh3D.scaledCellToCellDistancesGmsh3D.scaledCellVolumesGmsh3D.scaledFaceAreasGmsh3D.scaledFaceToCellDistancesGmsh3D.xGmsh3D.yGmsh3D.z
GmshGrid2DGmshGrid2D.VTKCellDataSetGmshGrid2D.VTKFaceDataSetGmshGrid2D.__add__()GmshGrid2D.__div__()GmshGrid2D.__getstate__()GmshGrid2D.__mul__()GmshGrid2D.__radd__()GmshGrid2D.__repr__()GmshGrid2D.__rmul__()GmshGrid2D.__setstate__()GmshGrid2D.__sub__()GmshGrid2D.__truediv__()GmshGrid2D.aspect2DGmshGrid2D.cellCentersGmshGrid2D.cellDistanceVectorsGmshGrid2D.cellFaceIDsGmshGrid2D.cellToFaceDistanceVectorsGmshGrid2D.cellVolumesGmshGrid2D.extentsGmshGrid2D.exteriorFacesGmshGrid2D.extrude()GmshGrid2D.faceCentersGmshGrid2D.facesBackGmshGrid2D.facesBottomGmshGrid2D.facesDownGmshGrid2D.facesFrontGmshGrid2D.facesLeftGmshGrid2D.facesRightGmshGrid2D.facesTopGmshGrid2D.facesUpGmshGrid2D.getNearestCell()GmshGrid2D.interiorFaceCellIDsGmshGrid2D.interiorFaceIDsGmshGrid2D.interiorFacesGmshGrid2D.scaleGmshGrid2D.scaledCellDistancesGmshGrid2D.scaledCellToCellDistancesGmshGrid2D.scaledCellVolumesGmshGrid2D.scaledFaceAreasGmshGrid2D.scaledFaceToCellDistancesGmshGrid2D.xGmshGrid2D.yGmshGrid2D.z
GmshGrid3DGmshGrid3D.VTKCellDataSetGmshGrid3D.VTKFaceDataSetGmshGrid3D.__add__()GmshGrid3D.__div__()GmshGrid3D.__getstate__()GmshGrid3D.__mul__()GmshGrid3D.__radd__()GmshGrid3D.__repr__()GmshGrid3D.__rmul__()GmshGrid3D.__setstate__()GmshGrid3D.__sub__()GmshGrid3D.__truediv__()GmshGrid3D.aspect2DGmshGrid3D.cellCentersGmshGrid3D.cellDistanceVectorsGmshGrid3D.cellFaceIDsGmshGrid3D.cellToFaceDistanceVectorsGmshGrid3D.cellVolumesGmshGrid3D.extentsGmshGrid3D.exteriorFacesGmshGrid3D.faceCentersGmshGrid3D.facesBackGmshGrid3D.facesBottomGmshGrid3D.facesDownGmshGrid3D.facesFrontGmshGrid3D.facesLeftGmshGrid3D.facesRightGmshGrid3D.facesTopGmshGrid3D.facesUpGmshGrid3D.getNearestCell()GmshGrid3D.interiorFaceCellIDsGmshGrid3D.interiorFaceIDsGmshGrid3D.interiorFacesGmshGrid3D.scaleGmshGrid3D.scaledCellDistancesGmshGrid3D.scaledCellToCellDistancesGmshGrid3D.scaledCellVolumesGmshGrid3D.scaledFaceAreasGmshGrid3D.scaledFaceToCellDistancesGmshGrid3D.xGmshGrid3D.yGmshGrid3D.z
Grid1D()Grid2D()Grid3D()PeriodicGrid1DPeriodicGrid1D.VTKCellDataSetPeriodicGrid1D.VTKFaceDataSetPeriodicGrid1D.__add__()PeriodicGrid1D.__div__()PeriodicGrid1D.__getstate__()PeriodicGrid1D.__mul__()PeriodicGrid1D.__radd__()PeriodicGrid1D.__repr__()PeriodicGrid1D.__rmul__()PeriodicGrid1D.__setstate__()PeriodicGrid1D.__sub__()PeriodicGrid1D.__truediv__()PeriodicGrid1D.aspect2DPeriodicGrid1D.cellCentersPeriodicGrid1D.cellDistanceVectorsPeriodicGrid1D.cellFaceIDsPeriodicGrid1D.cellToFaceDistanceVectorsPeriodicGrid1D.cellVolumesPeriodicGrid1D.extentsPeriodicGrid1D.exteriorFacesPeriodicGrid1D.faceCentersPeriodicGrid1D.facesBackPeriodicGrid1D.facesBottomPeriodicGrid1D.facesDownPeriodicGrid1D.facesFrontPeriodicGrid1D.facesLeftPeriodicGrid1D.facesRightPeriodicGrid1D.facesTopPeriodicGrid1D.facesUpPeriodicGrid1D.getNearestCell()PeriodicGrid1D.interiorFaceCellIDsPeriodicGrid1D.interiorFaceIDsPeriodicGrid1D.interiorFacesPeriodicGrid1D.scalePeriodicGrid1D.scaledCellDistancesPeriodicGrid1D.scaledCellToCellDistancesPeriodicGrid1D.scaledCellVolumesPeriodicGrid1D.scaledFaceAreasPeriodicGrid1D.scaledFaceToCellDistancesPeriodicGrid1D.xPeriodicGrid1D.yPeriodicGrid1D.z
PeriodicGrid2DPeriodicGrid2D.VTKCellDataSetPeriodicGrid2D.VTKFaceDataSetPeriodicGrid2D.__add__()PeriodicGrid2D.__div__()PeriodicGrid2D.__getstate__()PeriodicGrid2D.__mul__()PeriodicGrid2D.__radd__()PeriodicGrid2D.__repr__()PeriodicGrid2D.__rmul__()PeriodicGrid2D.__setstate__()PeriodicGrid2D.__sub__()PeriodicGrid2D.__truediv__()PeriodicGrid2D.aspect2DPeriodicGrid2D.cellCentersPeriodicGrid2D.cellDistanceVectorsPeriodicGrid2D.cellFaceIDsPeriodicGrid2D.cellToFaceDistanceVectorsPeriodicGrid2D.cellVolumesPeriodicGrid2D.extentsPeriodicGrid2D.exteriorFacesPeriodicGrid2D.extrude()PeriodicGrid2D.faceCentersPeriodicGrid2D.facesBackPeriodicGrid2D.facesBottomPeriodicGrid2D.facesDownPeriodicGrid2D.facesFrontPeriodicGrid2D.facesLeftPeriodicGrid2D.facesRightPeriodicGrid2D.facesTopPeriodicGrid2D.facesUpPeriodicGrid2D.getNearestCell()PeriodicGrid2D.interiorFaceCellIDsPeriodicGrid2D.interiorFaceIDsPeriodicGrid2D.interiorFacesPeriodicGrid2D.scalePeriodicGrid2D.scaledCellDistancesPeriodicGrid2D.scaledCellToCellDistancesPeriodicGrid2D.scaledCellVolumesPeriodicGrid2D.scaledFaceAreasPeriodicGrid2D.scaledFaceToCellDistancesPeriodicGrid2D.xPeriodicGrid2D.yPeriodicGrid2D.z
PeriodicGrid2DLeftRightPeriodicGrid2DLeftRight.VTKCellDataSetPeriodicGrid2DLeftRight.VTKFaceDataSetPeriodicGrid2DLeftRight.__add__()PeriodicGrid2DLeftRight.__div__()PeriodicGrid2DLeftRight.__getstate__()PeriodicGrid2DLeftRight.__mul__()PeriodicGrid2DLeftRight.__radd__()PeriodicGrid2DLeftRight.__repr__()PeriodicGrid2DLeftRight.__rmul__()PeriodicGrid2DLeftRight.__setstate__()PeriodicGrid2DLeftRight.__sub__()PeriodicGrid2DLeftRight.__truediv__()PeriodicGrid2DLeftRight.aspect2DPeriodicGrid2DLeftRight.cellCentersPeriodicGrid2DLeftRight.cellDistanceVectorsPeriodicGrid2DLeftRight.cellFaceIDsPeriodicGrid2DLeftRight.cellToFaceDistanceVectorsPeriodicGrid2DLeftRight.cellVolumesPeriodicGrid2DLeftRight.extentsPeriodicGrid2DLeftRight.exteriorFacesPeriodicGrid2DLeftRight.extrude()PeriodicGrid2DLeftRight.faceCentersPeriodicGrid2DLeftRight.facesBackPeriodicGrid2DLeftRight.facesBottomPeriodicGrid2DLeftRight.facesDownPeriodicGrid2DLeftRight.facesFrontPeriodicGrid2DLeftRight.facesLeftPeriodicGrid2DLeftRight.facesRightPeriodicGrid2DLeftRight.facesTopPeriodicGrid2DLeftRight.facesUpPeriodicGrid2DLeftRight.getNearestCell()PeriodicGrid2DLeftRight.interiorFaceCellIDsPeriodicGrid2DLeftRight.interiorFaceIDsPeriodicGrid2DLeftRight.interiorFacesPeriodicGrid2DLeftRight.scalePeriodicGrid2DLeftRight.scaledCellDistancesPeriodicGrid2DLeftRight.scaledCellToCellDistancesPeriodicGrid2DLeftRight.scaledCellVolumesPeriodicGrid2DLeftRight.scaledFaceAreasPeriodicGrid2DLeftRight.scaledFaceToCellDistancesPeriodicGrid2DLeftRight.xPeriodicGrid2DLeftRight.yPeriodicGrid2DLeftRight.z
PeriodicGrid2DTopBottomPeriodicGrid2DTopBottom.VTKCellDataSetPeriodicGrid2DTopBottom.VTKFaceDataSetPeriodicGrid2DTopBottom.__add__()PeriodicGrid2DTopBottom.__div__()PeriodicGrid2DTopBottom.__getstate__()PeriodicGrid2DTopBottom.__mul__()PeriodicGrid2DTopBottom.__radd__()PeriodicGrid2DTopBottom.__repr__()PeriodicGrid2DTopBottom.__rmul__()PeriodicGrid2DTopBottom.__setstate__()PeriodicGrid2DTopBottom.__sub__()PeriodicGrid2DTopBottom.__truediv__()PeriodicGrid2DTopBottom.aspect2DPeriodicGrid2DTopBottom.cellCentersPeriodicGrid2DTopBottom.cellDistanceVectorsPeriodicGrid2DTopBottom.cellFaceIDsPeriodicGrid2DTopBottom.cellToFaceDistanceVectorsPeriodicGrid2DTopBottom.cellVolumesPeriodicGrid2DTopBottom.extentsPeriodicGrid2DTopBottom.exteriorFacesPeriodicGrid2DTopBottom.extrude()PeriodicGrid2DTopBottom.faceCentersPeriodicGrid2DTopBottom.facesBackPeriodicGrid2DTopBottom.facesBottomPeriodicGrid2DTopBottom.facesDownPeriodicGrid2DTopBottom.facesFrontPeriodicGrid2DTopBottom.facesLeftPeriodicGrid2DTopBottom.facesRightPeriodicGrid2DTopBottom.facesTopPeriodicGrid2DTopBottom.facesUpPeriodicGrid2DTopBottom.getNearestCell()PeriodicGrid2DTopBottom.interiorFaceCellIDsPeriodicGrid2DTopBottom.interiorFaceIDsPeriodicGrid2DTopBottom.interiorFacesPeriodicGrid2DTopBottom.scalePeriodicGrid2DTopBottom.scaledCellDistancesPeriodicGrid2DTopBottom.scaledCellToCellDistancesPeriodicGrid2DTopBottom.scaledCellVolumesPeriodicGrid2DTopBottom.scaledFaceAreasPeriodicGrid2DTopBottom.scaledFaceToCellDistancesPeriodicGrid2DTopBottom.xPeriodicGrid2DTopBottom.yPeriodicGrid2DTopBottom.z
PeriodicGrid3DPeriodicGrid3D.VTKCellDataSetPeriodicGrid3D.VTKFaceDataSetPeriodicGrid3D.__add__()PeriodicGrid3D.__div__()PeriodicGrid3D.__getstate__()PeriodicGrid3D.__mul__()PeriodicGrid3D.__radd__()PeriodicGrid3D.__repr__()PeriodicGrid3D.__rmul__()PeriodicGrid3D.__setstate__()PeriodicGrid3D.__sub__()PeriodicGrid3D.__truediv__()PeriodicGrid3D.aspect2DPeriodicGrid3D.cellCentersPeriodicGrid3D.cellDistanceVectorsPeriodicGrid3D.cellFaceIDsPeriodicGrid3D.cellToFaceDistanceVectorsPeriodicGrid3D.cellVolumesPeriodicGrid3D.extentsPeriodicGrid3D.exteriorFacesPeriodicGrid3D.faceCentersPeriodicGrid3D.facesBackPeriodicGrid3D.facesBottomPeriodicGrid3D.facesDownPeriodicGrid3D.facesFrontPeriodicGrid3D.facesLeftPeriodicGrid3D.facesRightPeriodicGrid3D.facesTopPeriodicGrid3D.facesUpPeriodicGrid3D.getNearestCell()PeriodicGrid3D.interiorFaceCellIDsPeriodicGrid3D.interiorFaceIDsPeriodicGrid3D.interiorFacesPeriodicGrid3D.scalePeriodicGrid3D.scaledCellDistancesPeriodicGrid3D.scaledCellToCellDistancesPeriodicGrid3D.scaledCellVolumesPeriodicGrid3D.scaledFaceAreasPeriodicGrid3D.scaledFaceToCellDistancesPeriodicGrid3D.xPeriodicGrid3D.yPeriodicGrid3D.z
PeriodicGrid3DFrontBackPeriodicGrid3DFrontBack.VTKCellDataSetPeriodicGrid3DFrontBack.VTKFaceDataSetPeriodicGrid3DFrontBack.__add__()PeriodicGrid3DFrontBack.__div__()PeriodicGrid3DFrontBack.__getstate__()PeriodicGrid3DFrontBack.__mul__()PeriodicGrid3DFrontBack.__radd__()PeriodicGrid3DFrontBack.__repr__()PeriodicGrid3DFrontBack.__rmul__()PeriodicGrid3DFrontBack.__setstate__()PeriodicGrid3DFrontBack.__sub__()PeriodicGrid3DFrontBack.__truediv__()PeriodicGrid3DFrontBack.aspect2DPeriodicGrid3DFrontBack.cellCentersPeriodicGrid3DFrontBack.cellDistanceVectorsPeriodicGrid3DFrontBack.cellFaceIDsPeriodicGrid3DFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DFrontBack.cellVolumesPeriodicGrid3DFrontBack.extentsPeriodicGrid3DFrontBack.exteriorFacesPeriodicGrid3DFrontBack.faceCentersPeriodicGrid3DFrontBack.facesBackPeriodicGrid3DFrontBack.facesBottomPeriodicGrid3DFrontBack.facesDownPeriodicGrid3DFrontBack.facesFrontPeriodicGrid3DFrontBack.facesLeftPeriodicGrid3DFrontBack.facesRightPeriodicGrid3DFrontBack.facesTopPeriodicGrid3DFrontBack.facesUpPeriodicGrid3DFrontBack.getNearestCell()PeriodicGrid3DFrontBack.interiorFaceCellIDsPeriodicGrid3DFrontBack.interiorFaceIDsPeriodicGrid3DFrontBack.interiorFacesPeriodicGrid3DFrontBack.scalePeriodicGrid3DFrontBack.scaledCellDistancesPeriodicGrid3DFrontBack.scaledCellToCellDistancesPeriodicGrid3DFrontBack.scaledCellVolumesPeriodicGrid3DFrontBack.scaledFaceAreasPeriodicGrid3DFrontBack.scaledFaceToCellDistancesPeriodicGrid3DFrontBack.xPeriodicGrid3DFrontBack.yPeriodicGrid3DFrontBack.z
PeriodicGrid3DLeftRightPeriodicGrid3DLeftRight.VTKCellDataSetPeriodicGrid3DLeftRight.VTKFaceDataSetPeriodicGrid3DLeftRight.__add__()PeriodicGrid3DLeftRight.__div__()PeriodicGrid3DLeftRight.__getstate__()PeriodicGrid3DLeftRight.__mul__()PeriodicGrid3DLeftRight.__radd__()PeriodicGrid3DLeftRight.__repr__()PeriodicGrid3DLeftRight.__rmul__()PeriodicGrid3DLeftRight.__setstate__()PeriodicGrid3DLeftRight.__sub__()PeriodicGrid3DLeftRight.__truediv__()PeriodicGrid3DLeftRight.aspect2DPeriodicGrid3DLeftRight.cellCentersPeriodicGrid3DLeftRight.cellDistanceVectorsPeriodicGrid3DLeftRight.cellFaceIDsPeriodicGrid3DLeftRight.cellToFaceDistanceVectorsPeriodicGrid3DLeftRight.cellVolumesPeriodicGrid3DLeftRight.extentsPeriodicGrid3DLeftRight.exteriorFacesPeriodicGrid3DLeftRight.faceCentersPeriodicGrid3DLeftRight.facesBackPeriodicGrid3DLeftRight.facesBottomPeriodicGrid3DLeftRight.facesDownPeriodicGrid3DLeftRight.facesFrontPeriodicGrid3DLeftRight.facesLeftPeriodicGrid3DLeftRight.facesRightPeriodicGrid3DLeftRight.facesTopPeriodicGrid3DLeftRight.facesUpPeriodicGrid3DLeftRight.getNearestCell()PeriodicGrid3DLeftRight.interiorFaceCellIDsPeriodicGrid3DLeftRight.interiorFaceIDsPeriodicGrid3DLeftRight.interiorFacesPeriodicGrid3DLeftRight.scalePeriodicGrid3DLeftRight.scaledCellDistancesPeriodicGrid3DLeftRight.scaledCellToCellDistancesPeriodicGrid3DLeftRight.scaledCellVolumesPeriodicGrid3DLeftRight.scaledFaceAreasPeriodicGrid3DLeftRight.scaledFaceToCellDistancesPeriodicGrid3DLeftRight.xPeriodicGrid3DLeftRight.yPeriodicGrid3DLeftRight.z
PeriodicGrid3DLeftRightFrontBackPeriodicGrid3DLeftRightFrontBack.VTKCellDataSetPeriodicGrid3DLeftRightFrontBack.VTKFaceDataSetPeriodicGrid3DLeftRightFrontBack.__add__()PeriodicGrid3DLeftRightFrontBack.__div__()PeriodicGrid3DLeftRightFrontBack.__getstate__()PeriodicGrid3DLeftRightFrontBack.__mul__()PeriodicGrid3DLeftRightFrontBack.__radd__()PeriodicGrid3DLeftRightFrontBack.__repr__()PeriodicGrid3DLeftRightFrontBack.__rmul__()PeriodicGrid3DLeftRightFrontBack.__setstate__()PeriodicGrid3DLeftRightFrontBack.__sub__()PeriodicGrid3DLeftRightFrontBack.__truediv__()PeriodicGrid3DLeftRightFrontBack.aspect2DPeriodicGrid3DLeftRightFrontBack.cellCentersPeriodicGrid3DLeftRightFrontBack.cellDistanceVectorsPeriodicGrid3DLeftRightFrontBack.cellFaceIDsPeriodicGrid3DLeftRightFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DLeftRightFrontBack.cellVolumesPeriodicGrid3DLeftRightFrontBack.extentsPeriodicGrid3DLeftRightFrontBack.exteriorFacesPeriodicGrid3DLeftRightFrontBack.faceCentersPeriodicGrid3DLeftRightFrontBack.facesBackPeriodicGrid3DLeftRightFrontBack.facesBottomPeriodicGrid3DLeftRightFrontBack.facesDownPeriodicGrid3DLeftRightFrontBack.facesFrontPeriodicGrid3DLeftRightFrontBack.facesLeftPeriodicGrid3DLeftRightFrontBack.facesRightPeriodicGrid3DLeftRightFrontBack.facesTopPeriodicGrid3DLeftRightFrontBack.facesUpPeriodicGrid3DLeftRightFrontBack.getNearestCell()PeriodicGrid3DLeftRightFrontBack.interiorFaceCellIDsPeriodicGrid3DLeftRightFrontBack.interiorFaceIDsPeriodicGrid3DLeftRightFrontBack.interiorFacesPeriodicGrid3DLeftRightFrontBack.scalePeriodicGrid3DLeftRightFrontBack.scaledCellDistancesPeriodicGrid3DLeftRightFrontBack.scaledCellToCellDistancesPeriodicGrid3DLeftRightFrontBack.scaledCellVolumesPeriodicGrid3DLeftRightFrontBack.scaledFaceAreasPeriodicGrid3DLeftRightFrontBack.scaledFaceToCellDistancesPeriodicGrid3DLeftRightFrontBack.xPeriodicGrid3DLeftRightFrontBack.yPeriodicGrid3DLeftRightFrontBack.z
PeriodicGrid3DLeftRightTopBottomPeriodicGrid3DLeftRightTopBottom.VTKCellDataSetPeriodicGrid3DLeftRightTopBottom.VTKFaceDataSetPeriodicGrid3DLeftRightTopBottom.__add__()PeriodicGrid3DLeftRightTopBottom.__div__()PeriodicGrid3DLeftRightTopBottom.__getstate__()PeriodicGrid3DLeftRightTopBottom.__mul__()PeriodicGrid3DLeftRightTopBottom.__radd__()PeriodicGrid3DLeftRightTopBottom.__repr__()PeriodicGrid3DLeftRightTopBottom.__rmul__()PeriodicGrid3DLeftRightTopBottom.__setstate__()PeriodicGrid3DLeftRightTopBottom.__sub__()PeriodicGrid3DLeftRightTopBottom.__truediv__()PeriodicGrid3DLeftRightTopBottom.aspect2DPeriodicGrid3DLeftRightTopBottom.cellCentersPeriodicGrid3DLeftRightTopBottom.cellDistanceVectorsPeriodicGrid3DLeftRightTopBottom.cellFaceIDsPeriodicGrid3DLeftRightTopBottom.cellToFaceDistanceVectorsPeriodicGrid3DLeftRightTopBottom.cellVolumesPeriodicGrid3DLeftRightTopBottom.extentsPeriodicGrid3DLeftRightTopBottom.exteriorFacesPeriodicGrid3DLeftRightTopBottom.faceCentersPeriodicGrid3DLeftRightTopBottom.facesBackPeriodicGrid3DLeftRightTopBottom.facesBottomPeriodicGrid3DLeftRightTopBottom.facesDownPeriodicGrid3DLeftRightTopBottom.facesFrontPeriodicGrid3DLeftRightTopBottom.facesLeftPeriodicGrid3DLeftRightTopBottom.facesRightPeriodicGrid3DLeftRightTopBottom.facesTopPeriodicGrid3DLeftRightTopBottom.facesUpPeriodicGrid3DLeftRightTopBottom.getNearestCell()PeriodicGrid3DLeftRightTopBottom.interiorFaceCellIDsPeriodicGrid3DLeftRightTopBottom.interiorFaceIDsPeriodicGrid3DLeftRightTopBottom.interiorFacesPeriodicGrid3DLeftRightTopBottom.scalePeriodicGrid3DLeftRightTopBottom.scaledCellDistancesPeriodicGrid3DLeftRightTopBottom.scaledCellToCellDistancesPeriodicGrid3DLeftRightTopBottom.scaledCellVolumesPeriodicGrid3DLeftRightTopBottom.scaledFaceAreasPeriodicGrid3DLeftRightTopBottom.scaledFaceToCellDistancesPeriodicGrid3DLeftRightTopBottom.xPeriodicGrid3DLeftRightTopBottom.yPeriodicGrid3DLeftRightTopBottom.z
PeriodicGrid3DTopBottomPeriodicGrid3DTopBottom.VTKCellDataSetPeriodicGrid3DTopBottom.VTKFaceDataSetPeriodicGrid3DTopBottom.__add__()PeriodicGrid3DTopBottom.__div__()PeriodicGrid3DTopBottom.__getstate__()PeriodicGrid3DTopBottom.__mul__()PeriodicGrid3DTopBottom.__radd__()PeriodicGrid3DTopBottom.__repr__()PeriodicGrid3DTopBottom.__rmul__()PeriodicGrid3DTopBottom.__setstate__()PeriodicGrid3DTopBottom.__sub__()PeriodicGrid3DTopBottom.__truediv__()PeriodicGrid3DTopBottom.aspect2DPeriodicGrid3DTopBottom.cellCentersPeriodicGrid3DTopBottom.cellDistanceVectorsPeriodicGrid3DTopBottom.cellFaceIDsPeriodicGrid3DTopBottom.cellToFaceDistanceVectorsPeriodicGrid3DTopBottom.cellVolumesPeriodicGrid3DTopBottom.extentsPeriodicGrid3DTopBottom.exteriorFacesPeriodicGrid3DTopBottom.faceCentersPeriodicGrid3DTopBottom.facesBackPeriodicGrid3DTopBottom.facesBottomPeriodicGrid3DTopBottom.facesDownPeriodicGrid3DTopBottom.facesFrontPeriodicGrid3DTopBottom.facesLeftPeriodicGrid3DTopBottom.facesRightPeriodicGrid3DTopBottom.facesTopPeriodicGrid3DTopBottom.facesUpPeriodicGrid3DTopBottom.getNearestCell()PeriodicGrid3DTopBottom.interiorFaceCellIDsPeriodicGrid3DTopBottom.interiorFaceIDsPeriodicGrid3DTopBottom.interiorFacesPeriodicGrid3DTopBottom.scalePeriodicGrid3DTopBottom.scaledCellDistancesPeriodicGrid3DTopBottom.scaledCellToCellDistancesPeriodicGrid3DTopBottom.scaledCellVolumesPeriodicGrid3DTopBottom.scaledFaceAreasPeriodicGrid3DTopBottom.scaledFaceToCellDistancesPeriodicGrid3DTopBottom.xPeriodicGrid3DTopBottom.yPeriodicGrid3DTopBottom.z
PeriodicGrid3DTopBottomFrontBackPeriodicGrid3DTopBottomFrontBack.VTKCellDataSetPeriodicGrid3DTopBottomFrontBack.VTKFaceDataSetPeriodicGrid3DTopBottomFrontBack.__add__()PeriodicGrid3DTopBottomFrontBack.__div__()PeriodicGrid3DTopBottomFrontBack.__getstate__()PeriodicGrid3DTopBottomFrontBack.__mul__()PeriodicGrid3DTopBottomFrontBack.__radd__()PeriodicGrid3DTopBottomFrontBack.__repr__()PeriodicGrid3DTopBottomFrontBack.__rmul__()PeriodicGrid3DTopBottomFrontBack.__setstate__()PeriodicGrid3DTopBottomFrontBack.__sub__()PeriodicGrid3DTopBottomFrontBack.__truediv__()PeriodicGrid3DTopBottomFrontBack.aspect2DPeriodicGrid3DTopBottomFrontBack.cellCentersPeriodicGrid3DTopBottomFrontBack.cellDistanceVectorsPeriodicGrid3DTopBottomFrontBack.cellFaceIDsPeriodicGrid3DTopBottomFrontBack.cellToFaceDistanceVectorsPeriodicGrid3DTopBottomFrontBack.cellVolumesPeriodicGrid3DTopBottomFrontBack.extentsPeriodicGrid3DTopBottomFrontBack.exteriorFacesPeriodicGrid3DTopBottomFrontBack.faceCentersPeriodicGrid3DTopBottomFrontBack.facesBackPeriodicGrid3DTopBottomFrontBack.facesBottomPeriodicGrid3DTopBottomFrontBack.facesDownPeriodicGrid3DTopBottomFrontBack.facesFrontPeriodicGrid3DTopBottomFrontBack.facesLeftPeriodicGrid3DTopBottomFrontBack.facesRightPeriodicGrid3DTopBottomFrontBack.facesTopPeriodicGrid3DTopBottomFrontBack.facesUpPeriodicGrid3DTopBottomFrontBack.getNearestCell()PeriodicGrid3DTopBottomFrontBack.interiorFaceCellIDsPeriodicGrid3DTopBottomFrontBack.interiorFaceIDsPeriodicGrid3DTopBottomFrontBack.interiorFacesPeriodicGrid3DTopBottomFrontBack.scalePeriodicGrid3DTopBottomFrontBack.scaledCellDistancesPeriodicGrid3DTopBottomFrontBack.scaledCellToCellDistancesPeriodicGrid3DTopBottomFrontBack.scaledCellVolumesPeriodicGrid3DTopBottomFrontBack.scaledFaceAreasPeriodicGrid3DTopBottomFrontBack.scaledFaceToCellDistancesPeriodicGrid3DTopBottomFrontBack.xPeriodicGrid3DTopBottomFrontBack.yPeriodicGrid3DTopBottomFrontBack.z
SkewedGrid2DSkewedGrid2D.VTKCellDataSetSkewedGrid2D.VTKFaceDataSetSkewedGrid2D.__add__()SkewedGrid2D.__div__()SkewedGrid2D.__getstate__()SkewedGrid2D.__mul__()SkewedGrid2D.__radd__()SkewedGrid2D.__repr__()SkewedGrid2D.__rmul__()SkewedGrid2D.__setstate__()SkewedGrid2D.__sub__()SkewedGrid2D.__truediv__()SkewedGrid2D.aspect2DSkewedGrid2D.cellCentersSkewedGrid2D.cellDistanceVectorsSkewedGrid2D.cellFaceIDsSkewedGrid2D.cellToFaceDistanceVectorsSkewedGrid2D.cellVolumesSkewedGrid2D.extentsSkewedGrid2D.exteriorFacesSkewedGrid2D.extrude()SkewedGrid2D.faceCentersSkewedGrid2D.facesBackSkewedGrid2D.facesBottomSkewedGrid2D.facesDownSkewedGrid2D.facesFrontSkewedGrid2D.facesLeftSkewedGrid2D.facesRightSkewedGrid2D.facesTopSkewedGrid2D.facesUpSkewedGrid2D.getNearestCell()SkewedGrid2D.interiorFaceCellIDsSkewedGrid2D.interiorFaceIDsSkewedGrid2D.interiorFacesSkewedGrid2D.physicalShapeSkewedGrid2D.scaleSkewedGrid2D.scaledCellDistancesSkewedGrid2D.scaledCellToCellDistancesSkewedGrid2D.scaledCellVolumesSkewedGrid2D.scaledFaceAreasSkewedGrid2D.scaledFaceToCellDistancesSkewedGrid2D.shapeSkewedGrid2D.xSkewedGrid2D.ySkewedGrid2D.z
SphericalGrid1D()Tri2DTri2D.VTKCellDataSetTri2D.VTKFaceDataSetTri2D.__add__()Tri2D.__div__()Tri2D.__getstate__()Tri2D.__mul__()Tri2D.__radd__()Tri2D.__repr__()Tri2D.__rmul__()Tri2D.__setstate__()Tri2D.__sub__()Tri2D.__truediv__()Tri2D.aspect2DTri2D.cellCentersTri2D.cellDistanceVectorsTri2D.cellFaceIDsTri2D.cellToFaceDistanceVectorsTri2D.cellVolumesTri2D.extentsTri2D.exteriorFacesTri2D.extrude()Tri2D.faceCentersTri2D.facesBackTri2D.facesBottomTri2D.facesDownTri2D.facesFrontTri2D.facesLeftTri2D.facesRightTri2D.facesTopTri2D.facesUpTri2D.getNearestCell()Tri2D.interiorFaceCellIDsTri2D.interiorFaceIDsTri2D.interiorFacesTri2D.physicalShapeTri2D.scaleTri2D.scaledCellDistancesTri2D.scaledCellToCellDistancesTri2D.scaledCellVolumesTri2D.scaledFaceAreasTri2D.scaledFaceToCellDistancesTri2D.shapeTri2D.xTri2D.yTri2D.z
openMSHFile()openPOSFile()
- fipy.solvers package
- Subpackages
- fipy.solvers.petsc package
- Subpackages
- Submodules
- fipy.solvers.petsc.dummySolver module
- fipy.solvers.petsc.linearBicgSolver module
- fipy.solvers.petsc.linearCGSSolver module
- fipy.solvers.petsc.linearGMRESSolver module
- fipy.solvers.petsc.linearLUSolver module
- fipy.solvers.petsc.linearPCGSolver module
- fipy.solvers.petsc.petscKrylovSolver module
- fipy.solvers.petsc.petscSolver module
- Module contents
- fipy.solvers.pyAMG package
- fipy.solvers.pyamgx package
- Subpackages
- Submodules
- fipy.solvers.pyamgx.aggregationAMGSolver module
- fipy.solvers.pyamgx.classicalAMGSolver module
- fipy.solvers.pyamgx.linearBiCGStabSolver module
- fipy.solvers.pyamgx.linearCGSolver module
- fipy.solvers.pyamgx.linearFGMRESSolver module
- fipy.solvers.pyamgx.linearGMRESSolver module
- fipy.solvers.pyamgx.linearLUSolver module
- fipy.solvers.pyamgx.pyAMGXSolver module
- Module contents
- fipy.solvers.pysparse package
- Subpackages
- Submodules
- fipy.solvers.pysparse.linearCGSSolver module
- fipy.solvers.pysparse.linearGMRESSolver module
- fipy.solvers.pysparse.linearJORSolver module
- fipy.solvers.pysparse.linearLUSolver module
- fipy.solvers.pysparse.linearPCGSolver module
- fipy.solvers.pysparse.pysparseSolver module
- Module contents
- fipy.solvers.scipy package
- Submodules
- fipy.solvers.scipy.linearBicgstabSolver module
- fipy.solvers.scipy.linearCGSSolver module
- fipy.solvers.scipy.linearGMRESSolver module
- fipy.solvers.scipy.linearLUSolver module
- fipy.solvers.scipy.linearPCGSolver module
- fipy.solvers.scipy.scipyKrylovSolver module
- fipy.solvers.scipy.scipySolver module
- Module contents
- fipy.solvers.trilinos package
- Subpackages
- Submodules
- fipy.solvers.trilinos.linearBicgstabSolver module
- fipy.solvers.trilinos.linearCGSSolver module
- fipy.solvers.trilinos.linearGMRESSolver module
- fipy.solvers.trilinos.linearLUSolver module
- fipy.solvers.trilinos.linearPCGSolver module
- fipy.solvers.trilinos.trilinosAztecOOSolver module
- fipy.solvers.trilinos.trilinosMLTest module
- fipy.solvers.trilinos.trilinosNonlinearSolver module
- fipy.solvers.trilinos.trilinosSolver module
- Module contents
- fipy.solvers.petsc package
- Submodules
- fipy.solvers.pysparseMatrixSolver module
- fipy.solvers.solver module
IllConditionedPreconditionerWarningIllConditionedPreconditionerWarning.__cause__IllConditionedPreconditionerWarning.__context__IllConditionedPreconditionerWarning.__delattr__()IllConditionedPreconditionerWarning.__getattribute__()IllConditionedPreconditionerWarning.__reduce__()IllConditionedPreconditionerWarning.__repr__()IllConditionedPreconditionerWarning.__setattr__()IllConditionedPreconditionerWarning.__setstate__()IllConditionedPreconditionerWarning.__str__()IllConditionedPreconditionerWarning.__suppress_context__IllConditionedPreconditionerWarning.__traceback__IllConditionedPreconditionerWarning.argsIllConditionedPreconditionerWarning.with_traceback()
MatrixIllConditionedWarningMatrixIllConditionedWarning.__cause__MatrixIllConditionedWarning.__context__MatrixIllConditionedWarning.__delattr__()MatrixIllConditionedWarning.__getattribute__()MatrixIllConditionedWarning.__reduce__()MatrixIllConditionedWarning.__repr__()MatrixIllConditionedWarning.__setattr__()MatrixIllConditionedWarning.__setstate__()MatrixIllConditionedWarning.__str__()MatrixIllConditionedWarning.__suppress_context__MatrixIllConditionedWarning.__traceback__MatrixIllConditionedWarning.argsMatrixIllConditionedWarning.with_traceback()
MaximumIterationWarningMaximumIterationWarning.__cause__MaximumIterationWarning.__context__MaximumIterationWarning.__delattr__()MaximumIterationWarning.__getattribute__()MaximumIterationWarning.__reduce__()MaximumIterationWarning.__repr__()MaximumIterationWarning.__setattr__()MaximumIterationWarning.__setstate__()MaximumIterationWarning.__str__()MaximumIterationWarning.__suppress_context__MaximumIterationWarning.__traceback__MaximumIterationWarning.argsMaximumIterationWarning.with_traceback()
PreconditionerNotPositiveDefiniteWarningPreconditionerNotPositiveDefiniteWarning.__cause__PreconditionerNotPositiveDefiniteWarning.__context__PreconditionerNotPositiveDefiniteWarning.__delattr__()PreconditionerNotPositiveDefiniteWarning.__getattribute__()PreconditionerNotPositiveDefiniteWarning.__reduce__()PreconditionerNotPositiveDefiniteWarning.__repr__()PreconditionerNotPositiveDefiniteWarning.__setattr__()PreconditionerNotPositiveDefiniteWarning.__setstate__()PreconditionerNotPositiveDefiniteWarning.__str__()PreconditionerNotPositiveDefiniteWarning.__suppress_context__PreconditionerNotPositiveDefiniteWarning.__traceback__PreconditionerNotPositiveDefiniteWarning.argsPreconditionerNotPositiveDefiniteWarning.with_traceback()
PreconditionerWarningPreconditionerWarning.__cause__PreconditionerWarning.__context__PreconditionerWarning.__delattr__()PreconditionerWarning.__getattribute__()PreconditionerWarning.__reduce__()PreconditionerWarning.__repr__()PreconditionerWarning.__setattr__()PreconditionerWarning.__setstate__()PreconditionerWarning.__str__()PreconditionerWarning.__suppress_context__PreconditionerWarning.__traceback__PreconditionerWarning.argsPreconditionerWarning.with_traceback()
ScalarQuantityOutOfRangeWarningScalarQuantityOutOfRangeWarning.__cause__ScalarQuantityOutOfRangeWarning.__context__ScalarQuantityOutOfRangeWarning.__delattr__()ScalarQuantityOutOfRangeWarning.__getattribute__()ScalarQuantityOutOfRangeWarning.__reduce__()ScalarQuantityOutOfRangeWarning.__repr__()ScalarQuantityOutOfRangeWarning.__setattr__()ScalarQuantityOutOfRangeWarning.__setstate__()ScalarQuantityOutOfRangeWarning.__str__()ScalarQuantityOutOfRangeWarning.__suppress_context__ScalarQuantityOutOfRangeWarning.__traceback__ScalarQuantityOutOfRangeWarning.argsScalarQuantityOutOfRangeWarning.with_traceback()
SolverSolverConvergenceWarningSolverConvergenceWarning.__cause__SolverConvergenceWarning.__context__SolverConvergenceWarning.__delattr__()SolverConvergenceWarning.__getattribute__()SolverConvergenceWarning.__reduce__()SolverConvergenceWarning.__repr__()SolverConvergenceWarning.__setattr__()SolverConvergenceWarning.__setstate__()SolverConvergenceWarning.__str__()SolverConvergenceWarning.__suppress_context__SolverConvergenceWarning.__traceback__SolverConvergenceWarning.argsSolverConvergenceWarning.with_traceback()
StagnatedSolverWarningStagnatedSolverWarning.__cause__StagnatedSolverWarning.__context__StagnatedSolverWarning.__delattr__()StagnatedSolverWarning.__getattribute__()StagnatedSolverWarning.__reduce__()StagnatedSolverWarning.__repr__()StagnatedSolverWarning.__setattr__()StagnatedSolverWarning.__setstate__()StagnatedSolverWarning.__str__()StagnatedSolverWarning.__suppress_context__StagnatedSolverWarning.__traceback__StagnatedSolverWarning.argsStagnatedSolverWarning.with_traceback()
- fipy.solvers.test module
- Module contents
DefaultAsymmetricSolverDefaultSolverDummySolverGeneralSolverIllConditionedPreconditionerWarningIllConditionedPreconditionerWarning.__cause__IllConditionedPreconditionerWarning.__context__IllConditionedPreconditionerWarning.__delattr__()IllConditionedPreconditionerWarning.__getattribute__()IllConditionedPreconditionerWarning.__reduce__()IllConditionedPreconditionerWarning.__repr__()IllConditionedPreconditionerWarning.__setattr__()IllConditionedPreconditionerWarning.__setstate__()IllConditionedPreconditionerWarning.__str__()IllConditionedPreconditionerWarning.__suppress_context__IllConditionedPreconditionerWarning.__traceback__IllConditionedPreconditionerWarning.argsIllConditionedPreconditionerWarning.with_traceback()
LinearBicgstabSolverLinearCGSSolverLinearGMRESSolverLinearLUSolverLinearPCGSolverMatrixIllConditionedWarningMatrixIllConditionedWarning.__cause__MatrixIllConditionedWarning.__context__MatrixIllConditionedWarning.__delattr__()MatrixIllConditionedWarning.__getattribute__()MatrixIllConditionedWarning.__reduce__()MatrixIllConditionedWarning.__repr__()MatrixIllConditionedWarning.__setattr__()MatrixIllConditionedWarning.__setstate__()MatrixIllConditionedWarning.__str__()MatrixIllConditionedWarning.__suppress_context__MatrixIllConditionedWarning.__traceback__MatrixIllConditionedWarning.argsMatrixIllConditionedWarning.with_traceback()
MaximumIterationWarningMaximumIterationWarning.__cause__MaximumIterationWarning.__context__MaximumIterationWarning.__delattr__()MaximumIterationWarning.__getattribute__()MaximumIterationWarning.__reduce__()MaximumIterationWarning.__repr__()MaximumIterationWarning.__setattr__()MaximumIterationWarning.__setstate__()MaximumIterationWarning.__str__()MaximumIterationWarning.__suppress_context__MaximumIterationWarning.__traceback__MaximumIterationWarning.argsMaximumIterationWarning.with_traceback()
PreconditionerNotPositiveDefiniteWarningPreconditionerNotPositiveDefiniteWarning.__cause__PreconditionerNotPositiveDefiniteWarning.__context__PreconditionerNotPositiveDefiniteWarning.__delattr__()PreconditionerNotPositiveDefiniteWarning.__getattribute__()PreconditionerNotPositiveDefiniteWarning.__reduce__()PreconditionerNotPositiveDefiniteWarning.__repr__()PreconditionerNotPositiveDefiniteWarning.__setattr__()PreconditionerNotPositiveDefiniteWarning.__setstate__()PreconditionerNotPositiveDefiniteWarning.__str__()PreconditionerNotPositiveDefiniteWarning.__suppress_context__PreconditionerNotPositiveDefiniteWarning.__traceback__PreconditionerNotPositiveDefiniteWarning.argsPreconditionerNotPositiveDefiniteWarning.with_traceback()
PreconditionerWarningPreconditionerWarning.__cause__PreconditionerWarning.__context__PreconditionerWarning.__delattr__()PreconditionerWarning.__getattribute__()PreconditionerWarning.__reduce__()PreconditionerWarning.__repr__()PreconditionerWarning.__setattr__()PreconditionerWarning.__setstate__()PreconditionerWarning.__str__()PreconditionerWarning.__suppress_context__PreconditionerWarning.__traceback__PreconditionerWarning.argsPreconditionerWarning.with_traceback()
ScalarQuantityOutOfRangeWarningScalarQuantityOutOfRangeWarning.__cause__ScalarQuantityOutOfRangeWarning.__context__ScalarQuantityOutOfRangeWarning.__delattr__()ScalarQuantityOutOfRangeWarning.__getattribute__()ScalarQuantityOutOfRangeWarning.__reduce__()ScalarQuantityOutOfRangeWarning.__repr__()ScalarQuantityOutOfRangeWarning.__setattr__()ScalarQuantityOutOfRangeWarning.__setstate__()ScalarQuantityOutOfRangeWarning.__str__()ScalarQuantityOutOfRangeWarning.__suppress_context__ScalarQuantityOutOfRangeWarning.__traceback__ScalarQuantityOutOfRangeWarning.argsScalarQuantityOutOfRangeWarning.with_traceback()
SolverSolverConvergenceWarningSolverConvergenceWarning.__cause__SolverConvergenceWarning.__context__SolverConvergenceWarning.__delattr__()SolverConvergenceWarning.__getattribute__()SolverConvergenceWarning.__reduce__()SolverConvergenceWarning.__repr__()SolverConvergenceWarning.__setattr__()SolverConvergenceWarning.__setstate__()SolverConvergenceWarning.__str__()SolverConvergenceWarning.__suppress_context__SolverConvergenceWarning.__traceback__SolverConvergenceWarning.argsSolverConvergenceWarning.with_traceback()
StagnatedSolverWarningStagnatedSolverWarning.__cause__StagnatedSolverWarning.__context__StagnatedSolverWarning.__delattr__()StagnatedSolverWarning.__getattribute__()StagnatedSolverWarning.__reduce__()StagnatedSolverWarning.__repr__()StagnatedSolverWarning.__setattr__()StagnatedSolverWarning.__setstate__()StagnatedSolverWarning.__str__()StagnatedSolverWarning.__suppress_context__StagnatedSolverWarning.__traceback__StagnatedSolverWarning.argsStagnatedSolverWarning.with_traceback()
- Subpackages
- fipy.steppers package
- fipy.terms package
- Submodules
- fipy.terms.abstractBinaryTerm module
- fipy.terms.abstractConvectionTerm module
- fipy.terms.abstractDiffusionTerm module
- fipy.terms.abstractUpwindConvectionTerm module
- fipy.terms.advectionTerm module
AdvectionTermAdvectionTerm.RHSvectorAdvectionTerm.__add__()AdvectionTerm.__and__()AdvectionTerm.__div__()AdvectionTerm.__eq__()AdvectionTerm.__hash__()AdvectionTerm.__mul__()AdvectionTerm.__neg__()AdvectionTerm.__pos__()AdvectionTerm.__radd__()AdvectionTerm.__rand__()AdvectionTerm.__repr__()AdvectionTerm.__rmul__()AdvectionTerm.__rsub__()AdvectionTerm.__sub__()AdvectionTerm.__truediv__()AdvectionTerm.cacheMatrix()AdvectionTerm.cacheRHSvector()AdvectionTerm.copy()AdvectionTerm.getDefaultSolver()AdvectionTerm.justErrorVector()AdvectionTerm.justResidualVector()AdvectionTerm.matrixAdvectionTerm.residualVectorAndNorm()AdvectionTerm.solve()AdvectionTerm.sweep()
- fipy.terms.asymmetricConvectionTerm module
- fipy.terms.binaryTerm module
- fipy.terms.cellTerm module
CellTermCellTerm.RHSvectorCellTerm.__add__()CellTerm.__and__()CellTerm.__div__()CellTerm.__eq__()CellTerm.__hash__()CellTerm.__mul__()CellTerm.__neg__()CellTerm.__pos__()CellTerm.__radd__()CellTerm.__rand__()CellTerm.__repr__()CellTerm.__rmul__()CellTerm.__rsub__()CellTerm.__sub__()CellTerm.__truediv__()CellTerm.cacheMatrix()CellTerm.cacheRHSvector()CellTerm.copy()CellTerm.getDefaultSolver()CellTerm.justErrorVector()CellTerm.justResidualVector()CellTerm.matrixCellTerm.residualVectorAndNorm()CellTerm.solve()CellTerm.sweep()
- fipy.terms.centralDiffConvectionTerm module
CentralDifferenceConvectionTermCentralDifferenceConvectionTerm.RHSvectorCentralDifferenceConvectionTerm.__add__()CentralDifferenceConvectionTerm.__and__()CentralDifferenceConvectionTerm.__div__()CentralDifferenceConvectionTerm.__eq__()CentralDifferenceConvectionTerm.__hash__()CentralDifferenceConvectionTerm.__mul__()CentralDifferenceConvectionTerm.__neg__()CentralDifferenceConvectionTerm.__pos__()CentralDifferenceConvectionTerm.__radd__()CentralDifferenceConvectionTerm.__rand__()CentralDifferenceConvectionTerm.__repr__()CentralDifferenceConvectionTerm.__rmul__()CentralDifferenceConvectionTerm.__rsub__()CentralDifferenceConvectionTerm.__sub__()CentralDifferenceConvectionTerm.__truediv__()CentralDifferenceConvectionTerm.cacheMatrix()CentralDifferenceConvectionTerm.cacheRHSvector()CentralDifferenceConvectionTerm.copy()CentralDifferenceConvectionTerm.getDefaultSolver()CentralDifferenceConvectionTerm.justErrorVector()CentralDifferenceConvectionTerm.justResidualVector()CentralDifferenceConvectionTerm.matrixCentralDifferenceConvectionTerm.residualVectorAndNorm()CentralDifferenceConvectionTerm.solve()CentralDifferenceConvectionTerm.sweep()
- fipy.terms.coupledBinaryTerm module
- fipy.terms.diffusionTerm module
DiffusionTermDiffusionTerm.RHSvectorDiffusionTerm.__add__()DiffusionTerm.__and__()DiffusionTerm.__div__()DiffusionTerm.__eq__()DiffusionTerm.__hash__()DiffusionTerm.__mul__()DiffusionTerm.__neg__()DiffusionTerm.__pos__()DiffusionTerm.__radd__()DiffusionTerm.__rand__()DiffusionTerm.__repr__()DiffusionTerm.__rmul__()DiffusionTerm.__rsub__()DiffusionTerm.__sub__()DiffusionTerm.__truediv__()DiffusionTerm.cacheMatrix()DiffusionTerm.cacheRHSvector()DiffusionTerm.copy()DiffusionTerm.getDefaultSolver()DiffusionTerm.justErrorVector()DiffusionTerm.justResidualVector()DiffusionTerm.matrixDiffusionTerm.residualVectorAndNorm()DiffusionTerm.solve()DiffusionTerm.sweep()
DiffusionTermCorrectionDiffusionTermCorrection.RHSvectorDiffusionTermCorrection.__add__()DiffusionTermCorrection.__and__()DiffusionTermCorrection.__div__()DiffusionTermCorrection.__eq__()DiffusionTermCorrection.__hash__()DiffusionTermCorrection.__mul__()DiffusionTermCorrection.__neg__()DiffusionTermCorrection.__pos__()DiffusionTermCorrection.__radd__()DiffusionTermCorrection.__rand__()DiffusionTermCorrection.__repr__()DiffusionTermCorrection.__rmul__()DiffusionTermCorrection.__rsub__()DiffusionTermCorrection.__sub__()DiffusionTermCorrection.__truediv__()DiffusionTermCorrection.cacheMatrix()DiffusionTermCorrection.cacheRHSvector()DiffusionTermCorrection.copy()DiffusionTermCorrection.getDefaultSolver()DiffusionTermCorrection.justErrorVector()DiffusionTermCorrection.justResidualVector()DiffusionTermCorrection.matrixDiffusionTermCorrection.residualVectorAndNorm()DiffusionTermCorrection.solve()DiffusionTermCorrection.sweep()
DiffusionTermNoCorrectionDiffusionTermNoCorrection.RHSvectorDiffusionTermNoCorrection.__add__()DiffusionTermNoCorrection.__and__()DiffusionTermNoCorrection.__div__()DiffusionTermNoCorrection.__eq__()DiffusionTermNoCorrection.__hash__()DiffusionTermNoCorrection.__mul__()DiffusionTermNoCorrection.__neg__()DiffusionTermNoCorrection.__pos__()DiffusionTermNoCorrection.__radd__()DiffusionTermNoCorrection.__rand__()DiffusionTermNoCorrection.__repr__()DiffusionTermNoCorrection.__rmul__()DiffusionTermNoCorrection.__rsub__()DiffusionTermNoCorrection.__sub__()DiffusionTermNoCorrection.__truediv__()DiffusionTermNoCorrection.cacheMatrix()DiffusionTermNoCorrection.cacheRHSvector()DiffusionTermNoCorrection.copy()DiffusionTermNoCorrection.getDefaultSolver()DiffusionTermNoCorrection.justErrorVector()DiffusionTermNoCorrection.justResidualVector()DiffusionTermNoCorrection.matrixDiffusionTermNoCorrection.residualVectorAndNorm()DiffusionTermNoCorrection.solve()DiffusionTermNoCorrection.sweep()
- fipy.terms.diffusionTermCorrection module
DiffusionTermCorrectionDiffusionTermCorrection.RHSvectorDiffusionTermCorrection.__add__()DiffusionTermCorrection.__and__()DiffusionTermCorrection.__div__()DiffusionTermCorrection.__eq__()DiffusionTermCorrection.__hash__()DiffusionTermCorrection.__mul__()DiffusionTermCorrection.__neg__()DiffusionTermCorrection.__pos__()DiffusionTermCorrection.__radd__()DiffusionTermCorrection.__rand__()DiffusionTermCorrection.__repr__()DiffusionTermCorrection.__rmul__()DiffusionTermCorrection.__rsub__()DiffusionTermCorrection.__sub__()DiffusionTermCorrection.__truediv__()DiffusionTermCorrection.cacheMatrix()DiffusionTermCorrection.cacheRHSvector()DiffusionTermCorrection.copy()DiffusionTermCorrection.getDefaultSolver()DiffusionTermCorrection.justErrorVector()DiffusionTermCorrection.justResidualVector()DiffusionTermCorrection.matrixDiffusionTermCorrection.residualVectorAndNorm()DiffusionTermCorrection.solve()DiffusionTermCorrection.sweep()
- fipy.terms.diffusionTermNoCorrection module
DiffusionTermNoCorrectionDiffusionTermNoCorrection.RHSvectorDiffusionTermNoCorrection.__add__()DiffusionTermNoCorrection.__and__()DiffusionTermNoCorrection.__div__()DiffusionTermNoCorrection.__eq__()DiffusionTermNoCorrection.__hash__()DiffusionTermNoCorrection.__mul__()DiffusionTermNoCorrection.__neg__()DiffusionTermNoCorrection.__pos__()DiffusionTermNoCorrection.__radd__()DiffusionTermNoCorrection.__rand__()DiffusionTermNoCorrection.__repr__()DiffusionTermNoCorrection.__rmul__()DiffusionTermNoCorrection.__rsub__()DiffusionTermNoCorrection.__sub__()DiffusionTermNoCorrection.__truediv__()DiffusionTermNoCorrection.cacheMatrix()DiffusionTermNoCorrection.cacheRHSvector()DiffusionTermNoCorrection.copy()DiffusionTermNoCorrection.getDefaultSolver()DiffusionTermNoCorrection.justErrorVector()DiffusionTermNoCorrection.justResidualVector()DiffusionTermNoCorrection.matrixDiffusionTermNoCorrection.residualVectorAndNorm()DiffusionTermNoCorrection.solve()DiffusionTermNoCorrection.sweep()
- fipy.terms.explicitDiffusionTerm module
ExplicitDiffusionTermExplicitDiffusionTerm.RHSvectorExplicitDiffusionTerm.__add__()ExplicitDiffusionTerm.__and__()ExplicitDiffusionTerm.__div__()ExplicitDiffusionTerm.__eq__()ExplicitDiffusionTerm.__hash__()ExplicitDiffusionTerm.__mul__()ExplicitDiffusionTerm.__neg__()ExplicitDiffusionTerm.__pos__()ExplicitDiffusionTerm.__radd__()ExplicitDiffusionTerm.__rand__()ExplicitDiffusionTerm.__repr__()ExplicitDiffusionTerm.__rmul__()ExplicitDiffusionTerm.__rsub__()ExplicitDiffusionTerm.__sub__()ExplicitDiffusionTerm.__truediv__()ExplicitDiffusionTerm.cacheMatrix()ExplicitDiffusionTerm.cacheRHSvector()ExplicitDiffusionTerm.copy()ExplicitDiffusionTerm.getDefaultSolver()ExplicitDiffusionTerm.justErrorVector()ExplicitDiffusionTerm.justResidualVector()ExplicitDiffusionTerm.matrixExplicitDiffusionTerm.residualVectorAndNorm()ExplicitDiffusionTerm.solve()ExplicitDiffusionTerm.sweep()
- fipy.terms.explicitSourceTerm module
- fipy.terms.explicitUpwindConvectionTerm module
ExplicitUpwindConvectionTermExplicitUpwindConvectionTerm.RHSvectorExplicitUpwindConvectionTerm.__add__()ExplicitUpwindConvectionTerm.__and__()ExplicitUpwindConvectionTerm.__div__()ExplicitUpwindConvectionTerm.__eq__()ExplicitUpwindConvectionTerm.__hash__()ExplicitUpwindConvectionTerm.__mul__()ExplicitUpwindConvectionTerm.__neg__()ExplicitUpwindConvectionTerm.__pos__()ExplicitUpwindConvectionTerm.__radd__()ExplicitUpwindConvectionTerm.__rand__()ExplicitUpwindConvectionTerm.__repr__()ExplicitUpwindConvectionTerm.__rmul__()ExplicitUpwindConvectionTerm.__rsub__()ExplicitUpwindConvectionTerm.__sub__()ExplicitUpwindConvectionTerm.__truediv__()ExplicitUpwindConvectionTerm.cacheMatrix()ExplicitUpwindConvectionTerm.cacheRHSvector()ExplicitUpwindConvectionTerm.copy()ExplicitUpwindConvectionTerm.getDefaultSolver()ExplicitUpwindConvectionTerm.justErrorVector()ExplicitUpwindConvectionTerm.justResidualVector()ExplicitUpwindConvectionTerm.matrixExplicitUpwindConvectionTerm.residualVectorAndNorm()ExplicitUpwindConvectionTerm.solve()ExplicitUpwindConvectionTerm.sweep()
- fipy.terms.exponentialConvectionTerm module
ExponentialConvectionTermExponentialConvectionTerm.RHSvectorExponentialConvectionTerm.__add__()ExponentialConvectionTerm.__and__()ExponentialConvectionTerm.__div__()ExponentialConvectionTerm.__eq__()ExponentialConvectionTerm.__hash__()ExponentialConvectionTerm.__mul__()ExponentialConvectionTerm.__neg__()ExponentialConvectionTerm.__pos__()ExponentialConvectionTerm.__radd__()ExponentialConvectionTerm.__rand__()ExponentialConvectionTerm.__repr__()ExponentialConvectionTerm.__rmul__()ExponentialConvectionTerm.__rsub__()ExponentialConvectionTerm.__sub__()ExponentialConvectionTerm.__truediv__()ExponentialConvectionTerm.cacheMatrix()ExponentialConvectionTerm.cacheRHSvector()ExponentialConvectionTerm.copy()ExponentialConvectionTerm.getDefaultSolver()ExponentialConvectionTerm.justErrorVector()ExponentialConvectionTerm.justResidualVector()ExponentialConvectionTerm.matrixExponentialConvectionTerm.residualVectorAndNorm()ExponentialConvectionTerm.solve()ExponentialConvectionTerm.sweep()
- fipy.terms.faceTerm module
FaceTermFaceTerm.RHSvectorFaceTerm.__add__()FaceTerm.__and__()FaceTerm.__div__()FaceTerm.__eq__()FaceTerm.__hash__()FaceTerm.__mul__()FaceTerm.__neg__()FaceTerm.__pos__()FaceTerm.__radd__()FaceTerm.__rand__()FaceTerm.__repr__()FaceTerm.__rmul__()FaceTerm.__rsub__()FaceTerm.__sub__()FaceTerm.__truediv__()FaceTerm.cacheMatrix()FaceTerm.cacheRHSvector()FaceTerm.copy()FaceTerm.getDefaultSolver()FaceTerm.justErrorVector()FaceTerm.justResidualVector()FaceTerm.matrixFaceTerm.residualVectorAndNorm()FaceTerm.solve()FaceTerm.sweep()
- fipy.terms.firstOrderAdvectionTerm module
FirstOrderAdvectionTermFirstOrderAdvectionTerm.RHSvectorFirstOrderAdvectionTerm.__add__()FirstOrderAdvectionTerm.__and__()FirstOrderAdvectionTerm.__div__()FirstOrderAdvectionTerm.__eq__()FirstOrderAdvectionTerm.__hash__()FirstOrderAdvectionTerm.__mul__()FirstOrderAdvectionTerm.__neg__()FirstOrderAdvectionTerm.__pos__()FirstOrderAdvectionTerm.__radd__()FirstOrderAdvectionTerm.__rand__()FirstOrderAdvectionTerm.__repr__()FirstOrderAdvectionTerm.__rmul__()FirstOrderAdvectionTerm.__rsub__()FirstOrderAdvectionTerm.__sub__()FirstOrderAdvectionTerm.__truediv__()FirstOrderAdvectionTerm.cacheMatrix()FirstOrderAdvectionTerm.cacheRHSvector()FirstOrderAdvectionTerm.copy()FirstOrderAdvectionTerm.getDefaultSolver()FirstOrderAdvectionTerm.justErrorVector()FirstOrderAdvectionTerm.justResidualVector()FirstOrderAdvectionTerm.matrixFirstOrderAdvectionTerm.residualVectorAndNorm()FirstOrderAdvectionTerm.solve()FirstOrderAdvectionTerm.sweep()
- fipy.terms.hybridConvectionTerm module
HybridConvectionTermHybridConvectionTerm.RHSvectorHybridConvectionTerm.__add__()HybridConvectionTerm.__and__()HybridConvectionTerm.__div__()HybridConvectionTerm.__eq__()HybridConvectionTerm.__hash__()HybridConvectionTerm.__mul__()HybridConvectionTerm.__neg__()HybridConvectionTerm.__pos__()HybridConvectionTerm.__radd__()HybridConvectionTerm.__rand__()HybridConvectionTerm.__repr__()HybridConvectionTerm.__rmul__()HybridConvectionTerm.__rsub__()HybridConvectionTerm.__sub__()HybridConvectionTerm.__truediv__()HybridConvectionTerm.cacheMatrix()HybridConvectionTerm.cacheRHSvector()HybridConvectionTerm.copy()HybridConvectionTerm.getDefaultSolver()HybridConvectionTerm.justErrorVector()HybridConvectionTerm.justResidualVector()HybridConvectionTerm.matrixHybridConvectionTerm.residualVectorAndNorm()HybridConvectionTerm.solve()HybridConvectionTerm.sweep()
- fipy.terms.implicitDiffusionTerm module
- fipy.terms.implicitSourceTerm module
ImplicitSourceTermImplicitSourceTerm.RHSvectorImplicitSourceTerm.__add__()ImplicitSourceTerm.__and__()ImplicitSourceTerm.__div__()ImplicitSourceTerm.__eq__()ImplicitSourceTerm.__hash__()ImplicitSourceTerm.__mul__()ImplicitSourceTerm.__neg__()ImplicitSourceTerm.__pos__()ImplicitSourceTerm.__radd__()ImplicitSourceTerm.__rand__()ImplicitSourceTerm.__repr__()ImplicitSourceTerm.__rmul__()ImplicitSourceTerm.__rsub__()ImplicitSourceTerm.__sub__()ImplicitSourceTerm.__truediv__()ImplicitSourceTerm.cacheMatrix()ImplicitSourceTerm.cacheRHSvector()ImplicitSourceTerm.copy()ImplicitSourceTerm.getDefaultSolver()ImplicitSourceTerm.justErrorVector()ImplicitSourceTerm.justResidualVector()ImplicitSourceTerm.matrixImplicitSourceTerm.residualVectorAndNorm()ImplicitSourceTerm.solve()ImplicitSourceTerm.sweep()
- fipy.terms.nonDiffusionTerm module
- fipy.terms.powerLawConvectionTerm module
PowerLawConvectionTermPowerLawConvectionTerm.RHSvectorPowerLawConvectionTerm.__add__()PowerLawConvectionTerm.__and__()PowerLawConvectionTerm.__div__()PowerLawConvectionTerm.__eq__()PowerLawConvectionTerm.__hash__()PowerLawConvectionTerm.__mul__()PowerLawConvectionTerm.__neg__()PowerLawConvectionTerm.__pos__()PowerLawConvectionTerm.__radd__()PowerLawConvectionTerm.__rand__()PowerLawConvectionTerm.__repr__()PowerLawConvectionTerm.__rmul__()PowerLawConvectionTerm.__rsub__()PowerLawConvectionTerm.__sub__()PowerLawConvectionTerm.__truediv__()PowerLawConvectionTerm.cacheMatrix()PowerLawConvectionTerm.cacheRHSvector()PowerLawConvectionTerm.copy()PowerLawConvectionTerm.getDefaultSolver()PowerLawConvectionTerm.justErrorVector()PowerLawConvectionTerm.justResidualVector()PowerLawConvectionTerm.matrixPowerLawConvectionTerm.residualVectorAndNorm()PowerLawConvectionTerm.solve()PowerLawConvectionTerm.sweep()
- fipy.terms.residualTerm module
ResidualTermResidualTerm.RHSvectorResidualTerm.__add__()ResidualTerm.__and__()ResidualTerm.__div__()ResidualTerm.__eq__()ResidualTerm.__hash__()ResidualTerm.__mul__()ResidualTerm.__neg__()ResidualTerm.__pos__()ResidualTerm.__radd__()ResidualTerm.__rand__()ResidualTerm.__repr__()ResidualTerm.__rmul__()ResidualTerm.__rsub__()ResidualTerm.__sub__()ResidualTerm.__truediv__()ResidualTerm.cacheMatrix()ResidualTerm.cacheRHSvector()ResidualTerm.copy()ResidualTerm.getDefaultSolver()ResidualTerm.justErrorVector()ResidualTerm.justResidualVector()ResidualTerm.matrixResidualTerm.residualVectorAndNorm()ResidualTerm.solve()ResidualTerm.sweep()
- fipy.terms.sourceTerm module
SourceTermSourceTerm.RHSvectorSourceTerm.__add__()SourceTerm.__and__()SourceTerm.__div__()SourceTerm.__eq__()SourceTerm.__hash__()SourceTerm.__mul__()SourceTerm.__neg__()SourceTerm.__pos__()SourceTerm.__radd__()SourceTerm.__rand__()SourceTerm.__repr__()SourceTerm.__rmul__()SourceTerm.__rsub__()SourceTerm.__sub__()SourceTerm.__truediv__()SourceTerm.cacheMatrix()SourceTerm.cacheRHSvector()SourceTerm.copy()SourceTerm.getDefaultSolver()SourceTerm.justErrorVector()SourceTerm.justResidualVector()SourceTerm.matrixSourceTerm.residualVectorAndNorm()SourceTerm.solve()SourceTerm.sweep()
- fipy.terms.term module
TermTerm.RHSvectorTerm.__add__()Term.__and__()Term.__div__()Term.__eq__()Term.__hash__()Term.__mul__()Term.__neg__()Term.__pos__()Term.__radd__()Term.__rand__()Term.__repr__()Term.__rmul__()Term.__rsub__()Term.__sub__()Term.__truediv__()Term.cacheMatrix()Term.cacheRHSvector()Term.copy()Term.getDefaultSolver()Term.justErrorVector()Term.justResidualVector()Term.matrixTerm.residualVectorAndNorm()Term.solve()Term.sweep()
- fipy.terms.test module
- fipy.terms.transientTerm module
TransientTermTransientTerm.RHSvectorTransientTerm.__add__()TransientTerm.__and__()TransientTerm.__div__()TransientTerm.__eq__()TransientTerm.__hash__()TransientTerm.__mul__()TransientTerm.__neg__()TransientTerm.__pos__()TransientTerm.__radd__()TransientTerm.__rand__()TransientTerm.__repr__()TransientTerm.__rmul__()TransientTerm.__rsub__()TransientTerm.__sub__()TransientTerm.__truediv__()TransientTerm.cacheMatrix()TransientTerm.cacheRHSvector()TransientTerm.copy()TransientTerm.getDefaultSolver()TransientTerm.justErrorVector()TransientTerm.justResidualVector()TransientTerm.matrixTransientTerm.residualVectorAndNorm()TransientTerm.solve()TransientTerm.sweep()
- fipy.terms.unaryTerm module
- fipy.terms.upwindConvectionTerm module
UpwindConvectionTermUpwindConvectionTerm.RHSvectorUpwindConvectionTerm.__add__()UpwindConvectionTerm.__and__()UpwindConvectionTerm.__div__()UpwindConvectionTerm.__eq__()UpwindConvectionTerm.__hash__()UpwindConvectionTerm.__mul__()UpwindConvectionTerm.__neg__()UpwindConvectionTerm.__pos__()UpwindConvectionTerm.__radd__()UpwindConvectionTerm.__rand__()UpwindConvectionTerm.__repr__()UpwindConvectionTerm.__rmul__()UpwindConvectionTerm.__rsub__()UpwindConvectionTerm.__sub__()UpwindConvectionTerm.__truediv__()UpwindConvectionTerm.cacheMatrix()UpwindConvectionTerm.cacheRHSvector()UpwindConvectionTerm.copy()UpwindConvectionTerm.getDefaultSolver()UpwindConvectionTerm.justErrorVector()UpwindConvectionTerm.justResidualVector()UpwindConvectionTerm.matrixUpwindConvectionTerm.residualVectorAndNorm()UpwindConvectionTerm.solve()UpwindConvectionTerm.sweep()
- fipy.terms.vanLeerConvectionTerm module
VanLeerConvectionTermVanLeerConvectionTerm.RHSvectorVanLeerConvectionTerm.__add__()VanLeerConvectionTerm.__and__()VanLeerConvectionTerm.__div__()VanLeerConvectionTerm.__eq__()VanLeerConvectionTerm.__hash__()VanLeerConvectionTerm.__mul__()VanLeerConvectionTerm.__neg__()VanLeerConvectionTerm.__pos__()VanLeerConvectionTerm.__radd__()VanLeerConvectionTerm.__rand__()VanLeerConvectionTerm.__repr__()VanLeerConvectionTerm.__rmul__()VanLeerConvectionTerm.__rsub__()VanLeerConvectionTerm.__sub__()VanLeerConvectionTerm.__truediv__()VanLeerConvectionTerm.cacheMatrix()VanLeerConvectionTerm.cacheRHSvector()VanLeerConvectionTerm.copy()VanLeerConvectionTerm.getDefaultSolver()VanLeerConvectionTerm.justErrorVector()VanLeerConvectionTerm.justResidualVector()VanLeerConvectionTerm.matrixVanLeerConvectionTerm.residualVectorAndNorm()VanLeerConvectionTerm.solve()VanLeerConvectionTerm.sweep()
- Module contents
AbstractBaseClassErrorAbstractBaseClassError.__cause__AbstractBaseClassError.__context__AbstractBaseClassError.__delattr__()AbstractBaseClassError.__getattribute__()AbstractBaseClassError.__reduce__()AbstractBaseClassError.__repr__()AbstractBaseClassError.__setattr__()AbstractBaseClassError.__setstate__()AbstractBaseClassError.__str__()AbstractBaseClassError.__suppress_context__AbstractBaseClassError.__traceback__AbstractBaseClassError.argsAbstractBaseClassError.with_traceback()
AdvectionTermAdvectionTerm.RHSvectorAdvectionTerm.__add__()AdvectionTerm.__and__()AdvectionTerm.__div__()AdvectionTerm.__eq__()AdvectionTerm.__hash__()AdvectionTerm.__mul__()AdvectionTerm.__neg__()AdvectionTerm.__pos__()AdvectionTerm.__radd__()AdvectionTerm.__rand__()AdvectionTerm.__repr__()AdvectionTerm.__rmul__()AdvectionTerm.__rsub__()AdvectionTerm.__sub__()AdvectionTerm.__truediv__()AdvectionTerm.cacheMatrix()AdvectionTerm.cacheRHSvector()AdvectionTerm.copy()AdvectionTerm.getDefaultSolver()AdvectionTerm.justErrorVector()AdvectionTerm.justResidualVector()AdvectionTerm.matrixAdvectionTerm.residualVectorAndNorm()AdvectionTerm.solve()AdvectionTerm.sweep()
CentralDifferenceConvectionTermCentralDifferenceConvectionTerm.RHSvectorCentralDifferenceConvectionTerm.__add__()CentralDifferenceConvectionTerm.__and__()CentralDifferenceConvectionTerm.__div__()CentralDifferenceConvectionTerm.__eq__()CentralDifferenceConvectionTerm.__hash__()CentralDifferenceConvectionTerm.__mul__()CentralDifferenceConvectionTerm.__neg__()CentralDifferenceConvectionTerm.__pos__()CentralDifferenceConvectionTerm.__radd__()CentralDifferenceConvectionTerm.__rand__()CentralDifferenceConvectionTerm.__repr__()CentralDifferenceConvectionTerm.__rmul__()CentralDifferenceConvectionTerm.__rsub__()CentralDifferenceConvectionTerm.__sub__()CentralDifferenceConvectionTerm.__truediv__()CentralDifferenceConvectionTerm.cacheMatrix()CentralDifferenceConvectionTerm.cacheRHSvector()CentralDifferenceConvectionTerm.copy()CentralDifferenceConvectionTerm.getDefaultSolver()CentralDifferenceConvectionTerm.justErrorVector()CentralDifferenceConvectionTerm.justResidualVector()CentralDifferenceConvectionTerm.matrixCentralDifferenceConvectionTerm.residualVectorAndNorm()CentralDifferenceConvectionTerm.solve()CentralDifferenceConvectionTerm.sweep()
ConvectionTermDiffusionTermDiffusionTerm.RHSvectorDiffusionTerm.__add__()DiffusionTerm.__and__()DiffusionTerm.__div__()DiffusionTerm.__eq__()DiffusionTerm.__hash__()DiffusionTerm.__mul__()DiffusionTerm.__neg__()DiffusionTerm.__pos__()DiffusionTerm.__radd__()DiffusionTerm.__rand__()DiffusionTerm.__repr__()DiffusionTerm.__rmul__()DiffusionTerm.__rsub__()DiffusionTerm.__sub__()DiffusionTerm.__truediv__()DiffusionTerm.cacheMatrix()DiffusionTerm.cacheRHSvector()DiffusionTerm.copy()DiffusionTerm.getDefaultSolver()DiffusionTerm.justErrorVector()DiffusionTerm.justResidualVector()DiffusionTerm.matrixDiffusionTerm.residualVectorAndNorm()DiffusionTerm.solve()DiffusionTerm.sweep()
DiffusionTermCorrectionDiffusionTermCorrection.RHSvectorDiffusionTermCorrection.__add__()DiffusionTermCorrection.__and__()DiffusionTermCorrection.__div__()DiffusionTermCorrection.__eq__()DiffusionTermCorrection.__hash__()DiffusionTermCorrection.__mul__()DiffusionTermCorrection.__neg__()DiffusionTermCorrection.__pos__()DiffusionTermCorrection.__radd__()DiffusionTermCorrection.__rand__()DiffusionTermCorrection.__repr__()DiffusionTermCorrection.__rmul__()DiffusionTermCorrection.__rsub__()DiffusionTermCorrection.__sub__()DiffusionTermCorrection.__truediv__()DiffusionTermCorrection.cacheMatrix()DiffusionTermCorrection.cacheRHSvector()DiffusionTermCorrection.copy()DiffusionTermCorrection.getDefaultSolver()DiffusionTermCorrection.justErrorVector()DiffusionTermCorrection.justResidualVector()DiffusionTermCorrection.matrixDiffusionTermCorrection.residualVectorAndNorm()DiffusionTermCorrection.solve()DiffusionTermCorrection.sweep()
DiffusionTermNoCorrectionDiffusionTermNoCorrection.RHSvectorDiffusionTermNoCorrection.__add__()DiffusionTermNoCorrection.__and__()DiffusionTermNoCorrection.__div__()DiffusionTermNoCorrection.__eq__()DiffusionTermNoCorrection.__hash__()DiffusionTermNoCorrection.__mul__()DiffusionTermNoCorrection.__neg__()DiffusionTermNoCorrection.__pos__()DiffusionTermNoCorrection.__radd__()DiffusionTermNoCorrection.__rand__()DiffusionTermNoCorrection.__repr__()DiffusionTermNoCorrection.__rmul__()DiffusionTermNoCorrection.__rsub__()DiffusionTermNoCorrection.__sub__()DiffusionTermNoCorrection.__truediv__()DiffusionTermNoCorrection.cacheMatrix()DiffusionTermNoCorrection.cacheRHSvector()DiffusionTermNoCorrection.copy()DiffusionTermNoCorrection.getDefaultSolver()DiffusionTermNoCorrection.justErrorVector()DiffusionTermNoCorrection.justResidualVector()DiffusionTermNoCorrection.matrixDiffusionTermNoCorrection.residualVectorAndNorm()DiffusionTermNoCorrection.solve()DiffusionTermNoCorrection.sweep()
ExplicitDiffusionTermExplicitDiffusionTerm.RHSvectorExplicitDiffusionTerm.__add__()ExplicitDiffusionTerm.__and__()ExplicitDiffusionTerm.__div__()ExplicitDiffusionTerm.__eq__()ExplicitDiffusionTerm.__hash__()ExplicitDiffusionTerm.__mul__()ExplicitDiffusionTerm.__neg__()ExplicitDiffusionTerm.__pos__()ExplicitDiffusionTerm.__radd__()ExplicitDiffusionTerm.__rand__()ExplicitDiffusionTerm.__repr__()ExplicitDiffusionTerm.__rmul__()ExplicitDiffusionTerm.__rsub__()ExplicitDiffusionTerm.__sub__()ExplicitDiffusionTerm.__truediv__()ExplicitDiffusionTerm.cacheMatrix()ExplicitDiffusionTerm.cacheRHSvector()ExplicitDiffusionTerm.copy()ExplicitDiffusionTerm.getDefaultSolver()ExplicitDiffusionTerm.justErrorVector()ExplicitDiffusionTerm.justResidualVector()ExplicitDiffusionTerm.matrixExplicitDiffusionTerm.residualVectorAndNorm()ExplicitDiffusionTerm.solve()ExplicitDiffusionTerm.sweep()
ExplicitUpwindConvectionTermExplicitUpwindConvectionTerm.RHSvectorExplicitUpwindConvectionTerm.__add__()ExplicitUpwindConvectionTerm.__and__()ExplicitUpwindConvectionTerm.__div__()ExplicitUpwindConvectionTerm.__eq__()ExplicitUpwindConvectionTerm.__hash__()ExplicitUpwindConvectionTerm.__mul__()ExplicitUpwindConvectionTerm.__neg__()ExplicitUpwindConvectionTerm.__pos__()ExplicitUpwindConvectionTerm.__radd__()ExplicitUpwindConvectionTerm.__rand__()ExplicitUpwindConvectionTerm.__repr__()ExplicitUpwindConvectionTerm.__rmul__()ExplicitUpwindConvectionTerm.__rsub__()ExplicitUpwindConvectionTerm.__sub__()ExplicitUpwindConvectionTerm.__truediv__()ExplicitUpwindConvectionTerm.cacheMatrix()ExplicitUpwindConvectionTerm.cacheRHSvector()ExplicitUpwindConvectionTerm.copy()ExplicitUpwindConvectionTerm.getDefaultSolver()ExplicitUpwindConvectionTerm.justErrorVector()ExplicitUpwindConvectionTerm.justResidualVector()ExplicitUpwindConvectionTerm.matrixExplicitUpwindConvectionTerm.residualVectorAndNorm()ExplicitUpwindConvectionTerm.solve()ExplicitUpwindConvectionTerm.sweep()
ExplicitVariableErrorExplicitVariableError.__cause__ExplicitVariableError.__context__ExplicitVariableError.__delattr__()ExplicitVariableError.__getattribute__()ExplicitVariableError.__reduce__()ExplicitVariableError.__repr__()ExplicitVariableError.__setattr__()ExplicitVariableError.__setstate__()ExplicitVariableError.__str__()ExplicitVariableError.__suppress_context__ExplicitVariableError.__traceback__ExplicitVariableError.argsExplicitVariableError.with_traceback()
ExponentialConvectionTermExponentialConvectionTerm.RHSvectorExponentialConvectionTerm.__add__()ExponentialConvectionTerm.__and__()ExponentialConvectionTerm.__div__()ExponentialConvectionTerm.__eq__()ExponentialConvectionTerm.__hash__()ExponentialConvectionTerm.__mul__()ExponentialConvectionTerm.__neg__()ExponentialConvectionTerm.__pos__()ExponentialConvectionTerm.__radd__()ExponentialConvectionTerm.__rand__()ExponentialConvectionTerm.__repr__()ExponentialConvectionTerm.__rmul__()ExponentialConvectionTerm.__rsub__()ExponentialConvectionTerm.__sub__()ExponentialConvectionTerm.__truediv__()ExponentialConvectionTerm.cacheMatrix()ExponentialConvectionTerm.cacheRHSvector()ExponentialConvectionTerm.copy()ExponentialConvectionTerm.getDefaultSolver()ExponentialConvectionTerm.justErrorVector()ExponentialConvectionTerm.justResidualVector()ExponentialConvectionTerm.matrixExponentialConvectionTerm.residualVectorAndNorm()ExponentialConvectionTerm.solve()ExponentialConvectionTerm.sweep()
FirstOrderAdvectionTermFirstOrderAdvectionTerm.RHSvectorFirstOrderAdvectionTerm.__add__()FirstOrderAdvectionTerm.__and__()FirstOrderAdvectionTerm.__div__()FirstOrderAdvectionTerm.__eq__()FirstOrderAdvectionTerm.__hash__()FirstOrderAdvectionTerm.__mul__()FirstOrderAdvectionTerm.__neg__()FirstOrderAdvectionTerm.__pos__()FirstOrderAdvectionTerm.__radd__()FirstOrderAdvectionTerm.__rand__()FirstOrderAdvectionTerm.__repr__()FirstOrderAdvectionTerm.__rmul__()FirstOrderAdvectionTerm.__rsub__()FirstOrderAdvectionTerm.__sub__()FirstOrderAdvectionTerm.__truediv__()FirstOrderAdvectionTerm.cacheMatrix()FirstOrderAdvectionTerm.cacheRHSvector()FirstOrderAdvectionTerm.copy()FirstOrderAdvectionTerm.getDefaultSolver()FirstOrderAdvectionTerm.justErrorVector()FirstOrderAdvectionTerm.justResidualVector()FirstOrderAdvectionTerm.matrixFirstOrderAdvectionTerm.residualVectorAndNorm()FirstOrderAdvectionTerm.solve()FirstOrderAdvectionTerm.sweep()
HybridConvectionTermHybridConvectionTerm.RHSvectorHybridConvectionTerm.__add__()HybridConvectionTerm.__and__()HybridConvectionTerm.__div__()HybridConvectionTerm.__eq__()HybridConvectionTerm.__hash__()HybridConvectionTerm.__mul__()HybridConvectionTerm.__neg__()HybridConvectionTerm.__pos__()HybridConvectionTerm.__radd__()HybridConvectionTerm.__rand__()HybridConvectionTerm.__repr__()HybridConvectionTerm.__rmul__()HybridConvectionTerm.__rsub__()HybridConvectionTerm.__sub__()HybridConvectionTerm.__truediv__()HybridConvectionTerm.cacheMatrix()HybridConvectionTerm.cacheRHSvector()HybridConvectionTerm.copy()HybridConvectionTerm.getDefaultSolver()HybridConvectionTerm.justErrorVector()HybridConvectionTerm.justResidualVector()HybridConvectionTerm.matrixHybridConvectionTerm.residualVectorAndNorm()HybridConvectionTerm.solve()HybridConvectionTerm.sweep()
ImplicitDiffusionTermImplicitSourceTermImplicitSourceTerm.RHSvectorImplicitSourceTerm.__add__()ImplicitSourceTerm.__and__()ImplicitSourceTerm.__div__()ImplicitSourceTerm.__eq__()ImplicitSourceTerm.__hash__()ImplicitSourceTerm.__mul__()ImplicitSourceTerm.__neg__()ImplicitSourceTerm.__pos__()ImplicitSourceTerm.__radd__()ImplicitSourceTerm.__rand__()ImplicitSourceTerm.__repr__()ImplicitSourceTerm.__rmul__()ImplicitSourceTerm.__rsub__()ImplicitSourceTerm.__sub__()ImplicitSourceTerm.__truediv__()ImplicitSourceTerm.cacheMatrix()ImplicitSourceTerm.cacheRHSvector()ImplicitSourceTerm.copy()ImplicitSourceTerm.getDefaultSolver()ImplicitSourceTerm.justErrorVector()ImplicitSourceTerm.justResidualVector()ImplicitSourceTerm.matrixImplicitSourceTerm.residualVectorAndNorm()ImplicitSourceTerm.solve()ImplicitSourceTerm.sweep()
IncorrectSolutionVariableIncorrectSolutionVariable.__cause__IncorrectSolutionVariable.__context__IncorrectSolutionVariable.__delattr__()IncorrectSolutionVariable.__getattribute__()IncorrectSolutionVariable.__reduce__()IncorrectSolutionVariable.__repr__()IncorrectSolutionVariable.__setattr__()IncorrectSolutionVariable.__setstate__()IncorrectSolutionVariable.__str__()IncorrectSolutionVariable.__suppress_context__IncorrectSolutionVariable.__traceback__IncorrectSolutionVariable.argsIncorrectSolutionVariable.with_traceback()
PowerLawConvectionTermPowerLawConvectionTerm.RHSvectorPowerLawConvectionTerm.__add__()PowerLawConvectionTerm.__and__()PowerLawConvectionTerm.__div__()PowerLawConvectionTerm.__eq__()PowerLawConvectionTerm.__hash__()PowerLawConvectionTerm.__mul__()PowerLawConvectionTerm.__neg__()PowerLawConvectionTerm.__pos__()PowerLawConvectionTerm.__radd__()PowerLawConvectionTerm.__rand__()PowerLawConvectionTerm.__repr__()PowerLawConvectionTerm.__rmul__()PowerLawConvectionTerm.__rsub__()PowerLawConvectionTerm.__sub__()PowerLawConvectionTerm.__truediv__()PowerLawConvectionTerm.cacheMatrix()PowerLawConvectionTerm.cacheRHSvector()PowerLawConvectionTerm.copy()PowerLawConvectionTerm.getDefaultSolver()PowerLawConvectionTerm.justErrorVector()PowerLawConvectionTerm.justResidualVector()PowerLawConvectionTerm.matrixPowerLawConvectionTerm.residualVectorAndNorm()PowerLawConvectionTerm.solve()PowerLawConvectionTerm.sweep()
ResidualTermResidualTerm.RHSvectorResidualTerm.__add__()ResidualTerm.__and__()ResidualTerm.__div__()ResidualTerm.__eq__()ResidualTerm.__hash__()ResidualTerm.__mul__()ResidualTerm.__neg__()ResidualTerm.__pos__()ResidualTerm.__radd__()ResidualTerm.__rand__()ResidualTerm.__repr__()ResidualTerm.__rmul__()ResidualTerm.__rsub__()ResidualTerm.__sub__()ResidualTerm.__truediv__()ResidualTerm.cacheMatrix()ResidualTerm.cacheRHSvector()ResidualTerm.copy()ResidualTerm.getDefaultSolver()ResidualTerm.justErrorVector()ResidualTerm.justResidualVector()ResidualTerm.matrixResidualTerm.residualVectorAndNorm()ResidualTerm.solve()ResidualTerm.sweep()
SolutionVariableNumberErrorSolutionVariableNumberError.__cause__SolutionVariableNumberError.__context__SolutionVariableNumberError.__delattr__()SolutionVariableNumberError.__getattribute__()SolutionVariableNumberError.__reduce__()SolutionVariableNumberError.__repr__()SolutionVariableNumberError.__setattr__()SolutionVariableNumberError.__setstate__()SolutionVariableNumberError.__str__()SolutionVariableNumberError.__suppress_context__SolutionVariableNumberError.__traceback__SolutionVariableNumberError.argsSolutionVariableNumberError.with_traceback()
SolutionVariableRequiredErrorSolutionVariableRequiredError.__cause__SolutionVariableRequiredError.__context__SolutionVariableRequiredError.__delattr__()SolutionVariableRequiredError.__getattribute__()SolutionVariableRequiredError.__reduce__()SolutionVariableRequiredError.__repr__()SolutionVariableRequiredError.__setattr__()SolutionVariableRequiredError.__setstate__()SolutionVariableRequiredError.__str__()SolutionVariableRequiredError.__suppress_context__SolutionVariableRequiredError.__traceback__SolutionVariableRequiredError.argsSolutionVariableRequiredError.with_traceback()
TermMultiplyErrorTermMultiplyError.__cause__TermMultiplyError.__context__TermMultiplyError.__delattr__()TermMultiplyError.__getattribute__()TermMultiplyError.__reduce__()TermMultiplyError.__repr__()TermMultiplyError.__setattr__()TermMultiplyError.__setstate__()TermMultiplyError.__str__()TermMultiplyError.__suppress_context__TermMultiplyError.__traceback__TermMultiplyError.argsTermMultiplyError.with_traceback()
TransientTermTransientTerm.RHSvectorTransientTerm.__add__()TransientTerm.__and__()TransientTerm.__div__()TransientTerm.__eq__()TransientTerm.__hash__()TransientTerm.__mul__()TransientTerm.__neg__()TransientTerm.__pos__()TransientTerm.__radd__()TransientTerm.__rand__()TransientTerm.__repr__()TransientTerm.__rmul__()TransientTerm.__rsub__()TransientTerm.__sub__()TransientTerm.__truediv__()TransientTerm.cacheMatrix()TransientTerm.cacheRHSvector()TransientTerm.copy()TransientTerm.getDefaultSolver()TransientTerm.justErrorVector()TransientTerm.justResidualVector()TransientTerm.matrixTransientTerm.residualVectorAndNorm()TransientTerm.solve()TransientTerm.sweep()
UpwindConvectionTermUpwindConvectionTerm.RHSvectorUpwindConvectionTerm.__add__()UpwindConvectionTerm.__and__()UpwindConvectionTerm.__div__()UpwindConvectionTerm.__eq__()UpwindConvectionTerm.__hash__()UpwindConvectionTerm.__mul__()UpwindConvectionTerm.__neg__()UpwindConvectionTerm.__pos__()UpwindConvectionTerm.__radd__()UpwindConvectionTerm.__rand__()UpwindConvectionTerm.__repr__()UpwindConvectionTerm.__rmul__()UpwindConvectionTerm.__rsub__()UpwindConvectionTerm.__sub__()UpwindConvectionTerm.__truediv__()UpwindConvectionTerm.cacheMatrix()UpwindConvectionTerm.cacheRHSvector()UpwindConvectionTerm.copy()UpwindConvectionTerm.getDefaultSolver()UpwindConvectionTerm.justErrorVector()UpwindConvectionTerm.justResidualVector()UpwindConvectionTerm.matrixUpwindConvectionTerm.residualVectorAndNorm()UpwindConvectionTerm.solve()UpwindConvectionTerm.sweep()
VanLeerConvectionTermVanLeerConvectionTerm.RHSvectorVanLeerConvectionTerm.__add__()VanLeerConvectionTerm.__and__()VanLeerConvectionTerm.__div__()VanLeerConvectionTerm.__eq__()VanLeerConvectionTerm.__hash__()VanLeerConvectionTerm.__mul__()VanLeerConvectionTerm.__neg__()VanLeerConvectionTerm.__pos__()VanLeerConvectionTerm.__radd__()VanLeerConvectionTerm.__rand__()VanLeerConvectionTerm.__repr__()VanLeerConvectionTerm.__rmul__()VanLeerConvectionTerm.__rsub__()VanLeerConvectionTerm.__sub__()VanLeerConvectionTerm.__truediv__()VanLeerConvectionTerm.cacheMatrix()VanLeerConvectionTerm.cacheRHSvector()VanLeerConvectionTerm.copy()VanLeerConvectionTerm.getDefaultSolver()VanLeerConvectionTerm.justErrorVector()VanLeerConvectionTerm.justResidualVector()VanLeerConvectionTerm.matrixVanLeerConvectionTerm.residualVectorAndNorm()VanLeerConvectionTerm.solve()VanLeerConvectionTerm.sweep()
VectorCoeffErrorVectorCoeffError.__cause__VectorCoeffError.__context__VectorCoeffError.__delattr__()VectorCoeffError.__getattribute__()VectorCoeffError.__reduce__()VectorCoeffError.__repr__()VectorCoeffError.__setattr__()VectorCoeffError.__setstate__()VectorCoeffError.__str__()VectorCoeffError.__suppress_context__VectorCoeffError.__traceback__VectorCoeffError.argsVectorCoeffError.with_traceback()
- fipy.tests package
- fipy.tools package
- Subpackages
- Submodules
- fipy.tools.debug module
- fipy.tools.decorators module
- fipy.tools.dump module
- fipy.tools.inline module
- fipy.tools.numerix module
L1norm()L2norm()LINFnorm()all()allclose()allequal()dot()dtypedtype.__bool__()dtype.__eq__()dtype.__ge__()dtype.__getitem__()dtype.__gt__()dtype.__hash__()dtype.__le__()dtype.__len__()dtype.__lt__()dtype.__mul__()dtype.__ne__()dtype.__reduce__()dtype.__repr__()dtype.__rmul__()dtype.__setstate__()dtype.__str__()dtype.alignmentdtype.basedtype.byteorderdtype.chardtype.descrdtype.fieldsdtype.flagsdtype.hasobjectdtype.isalignedstructdtype.isbuiltindtype.isnativedtype.itemsizedtype.kinddtype.metadatadtype.namedtype.namesdtype.ndimdtype.newbyteorder()dtype.numdtype.shapedtype.strdtype.subdtypedtype.type
getShape()getUnit()isFloat()isInt()isclose()nearest()put()rank()reshape()sqrtDot()sum()take()tostring()
- fipy.tools.parser module
- fipy.tools.sharedtempfile module
- fipy.tools.test module
- fipy.tools.vector module
- fipy.tools.version module
- fipy.tools.vitals module
VitalsVitals.ATTRIBUTE_NODEVitals.CDATA_SECTION_NODEVitals.COMMENT_NODEVitals.DOCUMENT_FRAGMENT_NODEVitals.DOCUMENT_NODEVitals.DOCUMENT_TYPE_NODEVitals.ELEMENT_NODEVitals.ENTITY_NODEVitals.ENTITY_REFERENCE_NODEVitals.NOTATION_NODEVitals.PROCESSING_INSTRUCTION_NODEVitals.TEXT_NODEVitals.__slots__Vitals.__str__()Vitals.actualEncodingVitals.appendChild()Vitals.appendInfo()Vitals.async_Vitals.attributesVitals.childNodesVitals.dictToXML()Vitals.doctypeVitals.documentElementVitals.documentURIVitals.encodingVitals.errorHandlerVitals.firstChildVitals.implementationVitals.lastChildVitals.localNameVitals.namespaceURIVitals.nextSiblingVitals.nodeNameVitals.nodeTypeVitals.nodeValueVitals.ownerDocumentVitals.parentNodeVitals.prefixVitals.previousSiblingVitals.save()Vitals.standaloneVitals.strictErrorCheckingVitals.svn()Vitals.svncmd()Vitals.tupleToXML()Vitals.version
- Module contents
PhysicalFieldPhysicalField.__abs__()PhysicalField.__add__()PhysicalField.__array__()PhysicalField.__array_priority__PhysicalField.__array_wrap__()PhysicalField.__bool__()PhysicalField.__div__()PhysicalField.__eq__()PhysicalField.__float__()PhysicalField.__ge__()PhysicalField.__getitem__()PhysicalField.__gt__()PhysicalField.__hash__()PhysicalField.__le__()PhysicalField.__len__()PhysicalField.__lt__()PhysicalField.__mod__()PhysicalField.__mul__()PhysicalField.__ne__()PhysicalField.__neg__()PhysicalField.__nonzero__()PhysicalField.__pos__()PhysicalField.__pow__()PhysicalField.__radd__()PhysicalField.__rdiv__()PhysicalField.__repr__()PhysicalField.__rmul__()PhysicalField.__rpow__()PhysicalField.__rsub__()PhysicalField.__rtruediv__()PhysicalField.__setitem__()PhysicalField.__str__()PhysicalField.__sub__()PhysicalField.__truediv__()PhysicalField.add()PhysicalField.allclose()PhysicalField.allequal()PhysicalField.arccos()PhysicalField.arccosh()PhysicalField.arcsin()PhysicalField.arctan()PhysicalField.arctan2()PhysicalField.arctanh()PhysicalField.ceil()PhysicalField.conjugate()PhysicalField.convertToUnit()PhysicalField.copy()PhysicalField.cos()PhysicalField.cosh()PhysicalField.divide()PhysicalField.dot()PhysicalField.floor()PhysicalField.getsctype()PhysicalField.inBaseUnits()PhysicalField.inDimensionless()PhysicalField.inRadians()PhysicalField.inSIUnits()PhysicalField.inUnitsOf()PhysicalField.isCompatible()PhysicalField.itemset()PhysicalField.itemsizePhysicalField.log()PhysicalField.log10()PhysicalField.multiply()PhysicalField.numericValuePhysicalField.put()PhysicalField.ravel()PhysicalField.reshape()PhysicalField.shapePhysicalField.sign()PhysicalField.sin()PhysicalField.sinh()PhysicalField.sqrt()PhysicalField.subtract()PhysicalField.sum()PhysicalField.take()PhysicalField.tan()PhysicalField.tanh()PhysicalField.tostring()PhysicalField.unit
SharedTemporaryFile()VitalsVitals.ATTRIBUTE_NODEVitals.CDATA_SECTION_NODEVitals.COMMENT_NODEVitals.DOCUMENT_FRAGMENT_NODEVitals.DOCUMENT_NODEVitals.DOCUMENT_TYPE_NODEVitals.ELEMENT_NODEVitals.ENTITY_NODEVitals.ENTITY_REFERENCE_NODEVitals.NOTATION_NODEVitals.PROCESSING_INSTRUCTION_NODEVitals.TEXT_NODEVitals.__slots__Vitals.__str__()Vitals.actualEncodingVitals.appendChild()Vitals.appendInfo()Vitals.async_Vitals.attributesVitals.childNodesVitals.dictToXML()Vitals.doctypeVitals.documentElementVitals.documentURIVitals.encodingVitals.errorHandlerVitals.firstChildVitals.implementationVitals.lastChildVitals.localNameVitals.namespaceURIVitals.nextSiblingVitals.nodeNameVitals.nodeTypeVitals.nodeValueVitals.ownerDocumentVitals.parentNodeVitals.prefixVitals.previousSiblingVitals.save()Vitals.standaloneVitals.strictErrorCheckingVitals.svn()Vitals.svncmd()Vitals.tupleToXML()Vitals.version
- fipy.variables package
- Submodules
- fipy.variables.addOverFacesVariable module
- fipy.variables.arithmeticCellToFaceVariable module
- fipy.variables.betaNoiseVariable module
BetaNoiseVariableBetaNoiseVariable.__abs__()BetaNoiseVariable.__add__()BetaNoiseVariable.__and__()BetaNoiseVariable.__array__()BetaNoiseVariable.__array_priority__BetaNoiseVariable.__array_wrap__()BetaNoiseVariable.__bool__()BetaNoiseVariable.__call__()BetaNoiseVariable.__div__()BetaNoiseVariable.__eq__()BetaNoiseVariable.__float__()BetaNoiseVariable.__ge__()BetaNoiseVariable.__getitem__()BetaNoiseVariable.__getstate__()BetaNoiseVariable.__gt__()BetaNoiseVariable.__hash__()BetaNoiseVariable.__int__()BetaNoiseVariable.__invert__()BetaNoiseVariable.__iter__()BetaNoiseVariable.__le__()BetaNoiseVariable.__len__()BetaNoiseVariable.__lt__()BetaNoiseVariable.__mod__()BetaNoiseVariable.__mul__()BetaNoiseVariable.__ne__()BetaNoiseVariable.__neg__()BetaNoiseVariable.__new__()BetaNoiseVariable.__nonzero__()BetaNoiseVariable.__or__()BetaNoiseVariable.__pos__()BetaNoiseVariable.__pow__()BetaNoiseVariable.__radd__()BetaNoiseVariable.__rdiv__()BetaNoiseVariable.__repr__()BetaNoiseVariable.__rmul__()BetaNoiseVariable.__rpow__()BetaNoiseVariable.__rsub__()BetaNoiseVariable.__rtruediv__()BetaNoiseVariable.__setitem__()BetaNoiseVariable.__setstate__()BetaNoiseVariable.__str__()BetaNoiseVariable.__sub__()BetaNoiseVariable.__truediv__()BetaNoiseVariable.all()BetaNoiseVariable.allclose()BetaNoiseVariable.allequal()BetaNoiseVariable.any()BetaNoiseVariable.arithmeticFaceValueBetaNoiseVariable.cacheMe()BetaNoiseVariable.cellVolumeAverageBetaNoiseVariable.constrain()BetaNoiseVariable.constraintMaskBetaNoiseVariable.constraintsBetaNoiseVariable.copy()BetaNoiseVariable.dontCacheMe()BetaNoiseVariable.dot()BetaNoiseVariable.faceGradBetaNoiseVariable.faceGradAverageBetaNoiseVariable.faceValueBetaNoiseVariable.gaussGradBetaNoiseVariable.getsctype()BetaNoiseVariable.globalValueBetaNoiseVariable.gradBetaNoiseVariable.harmonicFaceValueBetaNoiseVariable.inBaseUnits()BetaNoiseVariable.inUnitsOf()BetaNoiseVariable.itemset()BetaNoiseVariable.itemsizeBetaNoiseVariable.leastSquaresGradBetaNoiseVariable.magBetaNoiseVariable.max()BetaNoiseVariable.min()BetaNoiseVariable.minmodFaceValueBetaNoiseVariable.nameBetaNoiseVariable.numericValueBetaNoiseVariable.oldBetaNoiseVariable.parallelRandom()BetaNoiseVariable.put()BetaNoiseVariable.random()BetaNoiseVariable.rankBetaNoiseVariable.ravel()BetaNoiseVariable.rdot()BetaNoiseVariable.release()BetaNoiseVariable.scramble()BetaNoiseVariable.setValue()BetaNoiseVariable.shapeBetaNoiseVariable.std()BetaNoiseVariable.subscribedVariablesBetaNoiseVariable.sum()BetaNoiseVariable.take()BetaNoiseVariable.tostring()BetaNoiseVariable.unitBetaNoiseVariable.updateOld()BetaNoiseVariable.value
- fipy.variables.binaryOperatorVariable module
- fipy.variables.cellToFaceVariable module
- fipy.variables.cellVariable module
CellVariableCellVariable.__abs__()CellVariable.__add__()CellVariable.__and__()CellVariable.__array__()CellVariable.__array_priority__CellVariable.__array_wrap__()CellVariable.__bool__()CellVariable.__call__()CellVariable.__div__()CellVariable.__eq__()CellVariable.__float__()CellVariable.__ge__()CellVariable.__getitem__()CellVariable.__getstate__()CellVariable.__gt__()CellVariable.__hash__()CellVariable.__int__()CellVariable.__invert__()CellVariable.__iter__()CellVariable.__le__()CellVariable.__len__()CellVariable.__lt__()CellVariable.__mod__()CellVariable.__mul__()CellVariable.__ne__()CellVariable.__neg__()CellVariable.__new__()CellVariable.__nonzero__()CellVariable.__or__()CellVariable.__pos__()CellVariable.__pow__()CellVariable.__radd__()CellVariable.__rdiv__()CellVariable.__repr__()CellVariable.__rmul__()CellVariable.__rpow__()CellVariable.__rsub__()CellVariable.__rtruediv__()CellVariable.__setitem__()CellVariable.__setstate__()CellVariable.__str__()CellVariable.__sub__()CellVariable.__truediv__()CellVariable.all()CellVariable.allclose()CellVariable.allequal()CellVariable.any()CellVariable.arithmeticFaceValueCellVariable.cacheMe()CellVariable.cellVolumeAverageCellVariable.constrain()CellVariable.constraintMaskCellVariable.constraintsCellVariable.copy()CellVariable.dontCacheMe()CellVariable.dot()CellVariable.faceGradCellVariable.faceGradAverageCellVariable.faceValueCellVariable.gaussGradCellVariable.getsctype()CellVariable.globalValueCellVariable.gradCellVariable.harmonicFaceValueCellVariable.inBaseUnits()CellVariable.inUnitsOf()CellVariable.itemset()CellVariable.itemsizeCellVariable.leastSquaresGradCellVariable.magCellVariable.max()CellVariable.min()CellVariable.minmodFaceValueCellVariable.nameCellVariable.numericValueCellVariable.oldCellVariable.put()CellVariable.rankCellVariable.ravel()CellVariable.rdot()CellVariable.release()CellVariable.setValue()CellVariable.shapeCellVariable.std()CellVariable.subscribedVariablesCellVariable.sum()CellVariable.take()CellVariable.tostring()CellVariable.unitCellVariable.updateOld()CellVariable.value
- fipy.variables.constant module
- fipy.variables.constraintMask module
- fipy.variables.coupledCellVariable module
- fipy.variables.distanceVariable module
DistanceVariableDistanceVariable.__abs__()DistanceVariable.__add__()DistanceVariable.__and__()DistanceVariable.__array__()DistanceVariable.__array_priority__DistanceVariable.__array_wrap__()DistanceVariable.__bool__()DistanceVariable.__call__()DistanceVariable.__div__()DistanceVariable.__eq__()DistanceVariable.__float__()DistanceVariable.__ge__()DistanceVariable.__getitem__()DistanceVariable.__getstate__()DistanceVariable.__gt__()DistanceVariable.__hash__()DistanceVariable.__int__()DistanceVariable.__invert__()DistanceVariable.__iter__()DistanceVariable.__le__()DistanceVariable.__len__()DistanceVariable.__lt__()DistanceVariable.__mod__()DistanceVariable.__mul__()DistanceVariable.__ne__()DistanceVariable.__neg__()DistanceVariable.__new__()DistanceVariable.__nonzero__()DistanceVariable.__or__()DistanceVariable.__pos__()DistanceVariable.__pow__()DistanceVariable.__radd__()DistanceVariable.__rdiv__()DistanceVariable.__repr__()DistanceVariable.__rmul__()DistanceVariable.__rpow__()DistanceVariable.__rsub__()DistanceVariable.__rtruediv__()DistanceVariable.__setitem__()DistanceVariable.__setstate__()DistanceVariable.__str__()DistanceVariable.__sub__()DistanceVariable.__truediv__()DistanceVariable.all()DistanceVariable.allclose()DistanceVariable.allequal()DistanceVariable.any()DistanceVariable.arithmeticFaceValueDistanceVariable.cacheMe()DistanceVariable.calcDistanceFunction()DistanceVariable.cellInterfaceAreasDistanceVariable.cellVolumeAverageDistanceVariable.constrain()DistanceVariable.constraintMaskDistanceVariable.constraintsDistanceVariable.copy()DistanceVariable.dontCacheMe()DistanceVariable.dot()DistanceVariable.extendVariable()DistanceVariable.faceGradDistanceVariable.faceGradAverageDistanceVariable.faceValueDistanceVariable.gaussGradDistanceVariable.getLSMshape()DistanceVariable.getsctype()DistanceVariable.globalValueDistanceVariable.gradDistanceVariable.harmonicFaceValueDistanceVariable.inBaseUnits()DistanceVariable.inUnitsOf()DistanceVariable.itemset()DistanceVariable.itemsizeDistanceVariable.leastSquaresGradDistanceVariable.magDistanceVariable.max()DistanceVariable.min()DistanceVariable.minmodFaceValueDistanceVariable.nameDistanceVariable.numericValueDistanceVariable.oldDistanceVariable.put()DistanceVariable.rankDistanceVariable.ravel()DistanceVariable.rdot()DistanceVariable.release()DistanceVariable.setValue()DistanceVariable.shapeDistanceVariable.std()DistanceVariable.subscribedVariablesDistanceVariable.sum()DistanceVariable.take()DistanceVariable.tostring()DistanceVariable.unitDistanceVariable.updateOld()DistanceVariable.value
- fipy.variables.exponentialNoiseVariable module
ExponentialNoiseVariableExponentialNoiseVariable.__abs__()ExponentialNoiseVariable.__add__()ExponentialNoiseVariable.__and__()ExponentialNoiseVariable.__array__()ExponentialNoiseVariable.__array_priority__ExponentialNoiseVariable.__array_wrap__()ExponentialNoiseVariable.__bool__()ExponentialNoiseVariable.__call__()ExponentialNoiseVariable.__div__()ExponentialNoiseVariable.__eq__()ExponentialNoiseVariable.__float__()ExponentialNoiseVariable.__ge__()ExponentialNoiseVariable.__getitem__()ExponentialNoiseVariable.__getstate__()ExponentialNoiseVariable.__gt__()ExponentialNoiseVariable.__hash__()ExponentialNoiseVariable.__int__()ExponentialNoiseVariable.__invert__()ExponentialNoiseVariable.__iter__()ExponentialNoiseVariable.__le__()ExponentialNoiseVariable.__len__()ExponentialNoiseVariable.__lt__()ExponentialNoiseVariable.__mod__()ExponentialNoiseVariable.__mul__()ExponentialNoiseVariable.__ne__()ExponentialNoiseVariable.__neg__()ExponentialNoiseVariable.__new__()ExponentialNoiseVariable.__nonzero__()ExponentialNoiseVariable.__or__()ExponentialNoiseVariable.__pos__()ExponentialNoiseVariable.__pow__()ExponentialNoiseVariable.__radd__()ExponentialNoiseVariable.__rdiv__()ExponentialNoiseVariable.__repr__()ExponentialNoiseVariable.__rmul__()ExponentialNoiseVariable.__rpow__()ExponentialNoiseVariable.__rsub__()ExponentialNoiseVariable.__rtruediv__()ExponentialNoiseVariable.__setitem__()ExponentialNoiseVariable.__setstate__()ExponentialNoiseVariable.__str__()ExponentialNoiseVariable.__sub__()ExponentialNoiseVariable.__truediv__()ExponentialNoiseVariable.all()ExponentialNoiseVariable.allclose()ExponentialNoiseVariable.allequal()ExponentialNoiseVariable.any()ExponentialNoiseVariable.arithmeticFaceValueExponentialNoiseVariable.cacheMe()ExponentialNoiseVariable.cellVolumeAverageExponentialNoiseVariable.constrain()ExponentialNoiseVariable.constraintMaskExponentialNoiseVariable.constraintsExponentialNoiseVariable.copy()ExponentialNoiseVariable.dontCacheMe()ExponentialNoiseVariable.dot()ExponentialNoiseVariable.faceGradExponentialNoiseVariable.faceGradAverageExponentialNoiseVariable.faceValueExponentialNoiseVariable.gaussGradExponentialNoiseVariable.getsctype()ExponentialNoiseVariable.globalValueExponentialNoiseVariable.gradExponentialNoiseVariable.harmonicFaceValueExponentialNoiseVariable.inBaseUnits()ExponentialNoiseVariable.inUnitsOf()ExponentialNoiseVariable.itemset()ExponentialNoiseVariable.itemsizeExponentialNoiseVariable.leastSquaresGradExponentialNoiseVariable.magExponentialNoiseVariable.max()ExponentialNoiseVariable.min()ExponentialNoiseVariable.minmodFaceValueExponentialNoiseVariable.nameExponentialNoiseVariable.numericValueExponentialNoiseVariable.oldExponentialNoiseVariable.parallelRandom()ExponentialNoiseVariable.put()ExponentialNoiseVariable.random()ExponentialNoiseVariable.rankExponentialNoiseVariable.ravel()ExponentialNoiseVariable.rdot()ExponentialNoiseVariable.release()ExponentialNoiseVariable.scramble()ExponentialNoiseVariable.setValue()ExponentialNoiseVariable.shapeExponentialNoiseVariable.std()ExponentialNoiseVariable.subscribedVariablesExponentialNoiseVariable.sum()ExponentialNoiseVariable.take()ExponentialNoiseVariable.tostring()ExponentialNoiseVariable.unitExponentialNoiseVariable.updateOld()ExponentialNoiseVariable.value
- fipy.variables.faceGradContributionsVariable module
- fipy.variables.faceGradVariable module
- fipy.variables.faceVariable module
FaceVariableFaceVariable.__abs__()FaceVariable.__add__()FaceVariable.__and__()FaceVariable.__array__()FaceVariable.__array_priority__FaceVariable.__array_wrap__()FaceVariable.__bool__()FaceVariable.__call__()FaceVariable.__div__()FaceVariable.__eq__()FaceVariable.__float__()FaceVariable.__ge__()FaceVariable.__getitem__()FaceVariable.__getstate__()FaceVariable.__gt__()FaceVariable.__hash__()FaceVariable.__int__()FaceVariable.__invert__()FaceVariable.__iter__()FaceVariable.__le__()FaceVariable.__len__()FaceVariable.__lt__()FaceVariable.__mod__()FaceVariable.__mul__()FaceVariable.__ne__()FaceVariable.__neg__()FaceVariable.__new__()FaceVariable.__nonzero__()FaceVariable.__or__()FaceVariable.__pos__()FaceVariable.__pow__()FaceVariable.__radd__()FaceVariable.__rdiv__()FaceVariable.__repr__()FaceVariable.__rmul__()FaceVariable.__rpow__()FaceVariable.__rsub__()FaceVariable.__rtruediv__()FaceVariable.__setitem__()FaceVariable.__setstate__()FaceVariable.__str__()FaceVariable.__sub__()FaceVariable.__truediv__()FaceVariable.all()FaceVariable.allclose()FaceVariable.allequal()FaceVariable.any()FaceVariable.cacheMe()FaceVariable.constrain()FaceVariable.constraintMaskFaceVariable.constraintsFaceVariable.copy()FaceVariable.divergenceFaceVariable.dontCacheMe()FaceVariable.dot()FaceVariable.getsctype()FaceVariable.globalValueFaceVariable.inBaseUnits()FaceVariable.inUnitsOf()FaceVariable.itemset()FaceVariable.itemsizeFaceVariable.magFaceVariable.max()FaceVariable.min()FaceVariable.nameFaceVariable.numericValueFaceVariable.put()FaceVariable.rankFaceVariable.ravel()FaceVariable.rdot()FaceVariable.release()FaceVariable.setValue()FaceVariable.shapeFaceVariable.std()FaceVariable.subscribedVariablesFaceVariable.sum()FaceVariable.take()FaceVariable.tostring()FaceVariable.unitFaceVariable.value
- fipy.variables.gammaNoiseVariable module
GammaNoiseVariableGammaNoiseVariable.__abs__()GammaNoiseVariable.__add__()GammaNoiseVariable.__and__()GammaNoiseVariable.__array__()GammaNoiseVariable.__array_priority__GammaNoiseVariable.__array_wrap__()GammaNoiseVariable.__bool__()GammaNoiseVariable.__call__()GammaNoiseVariable.__div__()GammaNoiseVariable.__eq__()GammaNoiseVariable.__float__()GammaNoiseVariable.__ge__()GammaNoiseVariable.__getitem__()GammaNoiseVariable.__getstate__()GammaNoiseVariable.__gt__()GammaNoiseVariable.__hash__()GammaNoiseVariable.__int__()GammaNoiseVariable.__invert__()GammaNoiseVariable.__iter__()GammaNoiseVariable.__le__()GammaNoiseVariable.__len__()GammaNoiseVariable.__lt__()GammaNoiseVariable.__mod__()GammaNoiseVariable.__mul__()GammaNoiseVariable.__ne__()GammaNoiseVariable.__neg__()GammaNoiseVariable.__new__()GammaNoiseVariable.__nonzero__()GammaNoiseVariable.__or__()GammaNoiseVariable.__pos__()GammaNoiseVariable.__pow__()GammaNoiseVariable.__radd__()GammaNoiseVariable.__rdiv__()GammaNoiseVariable.__repr__()GammaNoiseVariable.__rmul__()GammaNoiseVariable.__rpow__()GammaNoiseVariable.__rsub__()GammaNoiseVariable.__rtruediv__()GammaNoiseVariable.__setitem__()GammaNoiseVariable.__setstate__()GammaNoiseVariable.__str__()GammaNoiseVariable.__sub__()GammaNoiseVariable.__truediv__()GammaNoiseVariable.all()GammaNoiseVariable.allclose()GammaNoiseVariable.allequal()GammaNoiseVariable.any()GammaNoiseVariable.arithmeticFaceValueGammaNoiseVariable.cacheMe()GammaNoiseVariable.cellVolumeAverageGammaNoiseVariable.constrain()GammaNoiseVariable.constraintMaskGammaNoiseVariable.constraintsGammaNoiseVariable.copy()GammaNoiseVariable.dontCacheMe()GammaNoiseVariable.dot()GammaNoiseVariable.faceGradGammaNoiseVariable.faceGradAverageGammaNoiseVariable.faceValueGammaNoiseVariable.gaussGradGammaNoiseVariable.getsctype()GammaNoiseVariable.globalValueGammaNoiseVariable.gradGammaNoiseVariable.harmonicFaceValueGammaNoiseVariable.inBaseUnits()GammaNoiseVariable.inUnitsOf()GammaNoiseVariable.itemset()GammaNoiseVariable.itemsizeGammaNoiseVariable.leastSquaresGradGammaNoiseVariable.magGammaNoiseVariable.max()GammaNoiseVariable.min()GammaNoiseVariable.minmodFaceValueGammaNoiseVariable.nameGammaNoiseVariable.numericValueGammaNoiseVariable.oldGammaNoiseVariable.parallelRandom()GammaNoiseVariable.put()GammaNoiseVariable.random()GammaNoiseVariable.rankGammaNoiseVariable.ravel()GammaNoiseVariable.rdot()GammaNoiseVariable.release()GammaNoiseVariable.scramble()GammaNoiseVariable.setValue()GammaNoiseVariable.shapeGammaNoiseVariable.std()GammaNoiseVariable.subscribedVariablesGammaNoiseVariable.sum()GammaNoiseVariable.take()GammaNoiseVariable.tostring()GammaNoiseVariable.unitGammaNoiseVariable.updateOld()GammaNoiseVariable.value
- fipy.variables.gaussCellGradVariable module
- fipy.variables.gaussianNoiseVariable module
GaussianNoiseVariableGaussianNoiseVariable.__abs__()GaussianNoiseVariable.__add__()GaussianNoiseVariable.__and__()GaussianNoiseVariable.__array__()GaussianNoiseVariable.__array_priority__GaussianNoiseVariable.__array_wrap__()GaussianNoiseVariable.__bool__()GaussianNoiseVariable.__call__()GaussianNoiseVariable.__div__()GaussianNoiseVariable.__eq__()GaussianNoiseVariable.__float__()GaussianNoiseVariable.__ge__()GaussianNoiseVariable.__getitem__()GaussianNoiseVariable.__getstate__()GaussianNoiseVariable.__gt__()GaussianNoiseVariable.__hash__()GaussianNoiseVariable.__int__()GaussianNoiseVariable.__invert__()GaussianNoiseVariable.__iter__()GaussianNoiseVariable.__le__()GaussianNoiseVariable.__len__()GaussianNoiseVariable.__lt__()GaussianNoiseVariable.__mod__()GaussianNoiseVariable.__mul__()GaussianNoiseVariable.__ne__()GaussianNoiseVariable.__neg__()GaussianNoiseVariable.__new__()GaussianNoiseVariable.__nonzero__()GaussianNoiseVariable.__or__()GaussianNoiseVariable.__pos__()GaussianNoiseVariable.__pow__()GaussianNoiseVariable.__radd__()GaussianNoiseVariable.__rdiv__()GaussianNoiseVariable.__repr__()GaussianNoiseVariable.__rmul__()GaussianNoiseVariable.__rpow__()GaussianNoiseVariable.__rsub__()GaussianNoiseVariable.__rtruediv__()GaussianNoiseVariable.__setitem__()GaussianNoiseVariable.__setstate__()GaussianNoiseVariable.__str__()GaussianNoiseVariable.__sub__()GaussianNoiseVariable.__truediv__()GaussianNoiseVariable.all()GaussianNoiseVariable.allclose()GaussianNoiseVariable.allequal()GaussianNoiseVariable.any()GaussianNoiseVariable.arithmeticFaceValueGaussianNoiseVariable.cacheMe()GaussianNoiseVariable.cellVolumeAverageGaussianNoiseVariable.constrain()GaussianNoiseVariable.constraintMaskGaussianNoiseVariable.constraintsGaussianNoiseVariable.copy()GaussianNoiseVariable.dontCacheMe()GaussianNoiseVariable.dot()GaussianNoiseVariable.faceGradGaussianNoiseVariable.faceGradAverageGaussianNoiseVariable.faceValueGaussianNoiseVariable.gaussGradGaussianNoiseVariable.getsctype()GaussianNoiseVariable.globalValueGaussianNoiseVariable.gradGaussianNoiseVariable.harmonicFaceValueGaussianNoiseVariable.inBaseUnits()GaussianNoiseVariable.inUnitsOf()GaussianNoiseVariable.itemset()GaussianNoiseVariable.itemsizeGaussianNoiseVariable.leastSquaresGradGaussianNoiseVariable.magGaussianNoiseVariable.max()GaussianNoiseVariable.min()GaussianNoiseVariable.minmodFaceValueGaussianNoiseVariable.nameGaussianNoiseVariable.numericValueGaussianNoiseVariable.oldGaussianNoiseVariable.parallelRandom()GaussianNoiseVariable.put()GaussianNoiseVariable.random()GaussianNoiseVariable.rankGaussianNoiseVariable.ravel()GaussianNoiseVariable.rdot()GaussianNoiseVariable.release()GaussianNoiseVariable.scramble()GaussianNoiseVariable.setValue()GaussianNoiseVariable.shapeGaussianNoiseVariable.std()GaussianNoiseVariable.subscribedVariablesGaussianNoiseVariable.sum()GaussianNoiseVariable.take()GaussianNoiseVariable.tostring()GaussianNoiseVariable.unitGaussianNoiseVariable.updateOld()GaussianNoiseVariable.value
- fipy.variables.harmonicCellToFaceVariable module
- fipy.variables.histogramVariable module
HistogramVariableHistogramVariable.__abs__()HistogramVariable.__add__()HistogramVariable.__and__()HistogramVariable.__array__()HistogramVariable.__array_priority__HistogramVariable.__array_wrap__()HistogramVariable.__bool__()HistogramVariable.__call__()HistogramVariable.__div__()HistogramVariable.__eq__()HistogramVariable.__float__()HistogramVariable.__ge__()HistogramVariable.__getitem__()HistogramVariable.__getstate__()HistogramVariable.__gt__()HistogramVariable.__hash__()HistogramVariable.__int__()HistogramVariable.__invert__()HistogramVariable.__iter__()HistogramVariable.__le__()HistogramVariable.__len__()HistogramVariable.__lt__()HistogramVariable.__mod__()HistogramVariable.__mul__()HistogramVariable.__ne__()HistogramVariable.__neg__()HistogramVariable.__new__()HistogramVariable.__nonzero__()HistogramVariable.__or__()HistogramVariable.__pos__()HistogramVariable.__pow__()HistogramVariable.__radd__()HistogramVariable.__rdiv__()HistogramVariable.__repr__()HistogramVariable.__rmul__()HistogramVariable.__rpow__()HistogramVariable.__rsub__()HistogramVariable.__rtruediv__()HistogramVariable.__setitem__()HistogramVariable.__setstate__()HistogramVariable.__str__()HistogramVariable.__sub__()HistogramVariable.__truediv__()HistogramVariable.all()HistogramVariable.allclose()HistogramVariable.allequal()HistogramVariable.any()HistogramVariable.arithmeticFaceValueHistogramVariable.cacheMe()HistogramVariable.cellVolumeAverageHistogramVariable.constrain()HistogramVariable.constraintMaskHistogramVariable.constraintsHistogramVariable.copy()HistogramVariable.dontCacheMe()HistogramVariable.dot()HistogramVariable.faceGradHistogramVariable.faceGradAverageHistogramVariable.faceValueHistogramVariable.gaussGradHistogramVariable.getsctype()HistogramVariable.globalValueHistogramVariable.gradHistogramVariable.harmonicFaceValueHistogramVariable.inBaseUnits()HistogramVariable.inUnitsOf()HistogramVariable.itemset()HistogramVariable.itemsizeHistogramVariable.leastSquaresGradHistogramVariable.magHistogramVariable.max()HistogramVariable.min()HistogramVariable.minmodFaceValueHistogramVariable.nameHistogramVariable.numericValueHistogramVariable.oldHistogramVariable.put()HistogramVariable.rankHistogramVariable.ravel()HistogramVariable.rdot()HistogramVariable.release()HistogramVariable.setValue()HistogramVariable.shapeHistogramVariable.std()HistogramVariable.subscribedVariablesHistogramVariable.sum()HistogramVariable.take()HistogramVariable.tostring()HistogramVariable.unitHistogramVariable.updateOld()HistogramVariable.value
- fipy.variables.interfaceAreaVariable module
- fipy.variables.interfaceFlagVariable module
- fipy.variables.leastSquaresCellGradVariable module
- fipy.variables.levelSetDiffusionVariable module
- fipy.variables.meshVariable module
- fipy.variables.minmodCellToFaceVariable module
- fipy.variables.modCellGradVariable module
- fipy.variables.modCellToFaceVariable module
- fipy.variables.modFaceGradVariable module
- fipy.variables.modPhysicalField module
- fipy.variables.modularVariable module
ModularVariableModularVariable.__abs__()ModularVariable.__add__()ModularVariable.__and__()ModularVariable.__array__()ModularVariable.__array_priority__ModularVariable.__array_wrap__()ModularVariable.__bool__()ModularVariable.__call__()ModularVariable.__div__()ModularVariable.__eq__()ModularVariable.__float__()ModularVariable.__ge__()ModularVariable.__getitem__()ModularVariable.__getstate__()ModularVariable.__gt__()ModularVariable.__hash__()ModularVariable.__int__()ModularVariable.__invert__()ModularVariable.__iter__()ModularVariable.__le__()ModularVariable.__len__()ModularVariable.__lt__()ModularVariable.__mod__()ModularVariable.__mul__()ModularVariable.__ne__()ModularVariable.__neg__()ModularVariable.__new__()ModularVariable.__nonzero__()ModularVariable.__or__()ModularVariable.__pos__()ModularVariable.__pow__()ModularVariable.__radd__()ModularVariable.__rdiv__()ModularVariable.__repr__()ModularVariable.__rmul__()ModularVariable.__rpow__()ModularVariable.__rsub__()ModularVariable.__rtruediv__()ModularVariable.__setitem__()ModularVariable.__setstate__()ModularVariable.__str__()ModularVariable.__sub__()ModularVariable.__truediv__()ModularVariable.all()ModularVariable.allclose()ModularVariable.allequal()ModularVariable.any()ModularVariable.arithmeticFaceValueModularVariable.cacheMe()ModularVariable.cellVolumeAverageModularVariable.constrain()ModularVariable.constraintMaskModularVariable.constraintsModularVariable.copy()ModularVariable.dontCacheMe()ModularVariable.dot()ModularVariable.faceGradModularVariable.faceGradAverageModularVariable.faceGradNoModModularVariable.faceValueModularVariable.gaussGradModularVariable.getsctype()ModularVariable.globalValueModularVariable.gradModularVariable.harmonicFaceValueModularVariable.inBaseUnits()ModularVariable.inUnitsOf()ModularVariable.itemset()ModularVariable.itemsizeModularVariable.leastSquaresGradModularVariable.magModularVariable.max()ModularVariable.min()ModularVariable.minmodFaceValueModularVariable.nameModularVariable.numericValueModularVariable.oldModularVariable.put()ModularVariable.rankModularVariable.ravel()ModularVariable.rdot()ModularVariable.release()ModularVariable.setValue()ModularVariable.shapeModularVariable.std()ModularVariable.subscribedVariablesModularVariable.sum()ModularVariable.take()ModularVariable.tostring()ModularVariable.unitModularVariable.updateOld()ModularVariable.value
- fipy.variables.noiseVariable module
NoiseVariableNoiseVariable.__abs__()NoiseVariable.__add__()NoiseVariable.__and__()NoiseVariable.__array__()NoiseVariable.__array_priority__NoiseVariable.__array_wrap__()NoiseVariable.__bool__()NoiseVariable.__call__()NoiseVariable.__div__()NoiseVariable.__eq__()NoiseVariable.__float__()NoiseVariable.__ge__()NoiseVariable.__getitem__()NoiseVariable.__getstate__()NoiseVariable.__gt__()NoiseVariable.__hash__()NoiseVariable.__int__()NoiseVariable.__invert__()NoiseVariable.__iter__()NoiseVariable.__le__()NoiseVariable.__len__()NoiseVariable.__lt__()NoiseVariable.__mod__()NoiseVariable.__mul__()NoiseVariable.__ne__()NoiseVariable.__neg__()NoiseVariable.__new__()NoiseVariable.__nonzero__()NoiseVariable.__or__()NoiseVariable.__pos__()NoiseVariable.__pow__()NoiseVariable.__radd__()NoiseVariable.__rdiv__()NoiseVariable.__repr__()NoiseVariable.__rmul__()NoiseVariable.__rpow__()NoiseVariable.__rsub__()NoiseVariable.__rtruediv__()NoiseVariable.__setitem__()NoiseVariable.__setstate__()NoiseVariable.__str__()NoiseVariable.__sub__()NoiseVariable.__truediv__()NoiseVariable.all()NoiseVariable.allclose()NoiseVariable.allequal()NoiseVariable.any()NoiseVariable.arithmeticFaceValueNoiseVariable.cacheMe()NoiseVariable.cellVolumeAverageNoiseVariable.constrain()NoiseVariable.constraintMaskNoiseVariable.constraintsNoiseVariable.copy()NoiseVariable.dontCacheMe()NoiseVariable.dot()NoiseVariable.faceGradNoiseVariable.faceGradAverageNoiseVariable.faceValueNoiseVariable.gaussGradNoiseVariable.getsctype()NoiseVariable.globalValueNoiseVariable.gradNoiseVariable.harmonicFaceValueNoiseVariable.inBaseUnits()NoiseVariable.inUnitsOf()NoiseVariable.itemset()NoiseVariable.itemsizeNoiseVariable.leastSquaresGradNoiseVariable.magNoiseVariable.max()NoiseVariable.min()NoiseVariable.minmodFaceValueNoiseVariable.nameNoiseVariable.numericValueNoiseVariable.oldNoiseVariable.parallelRandom()NoiseVariable.put()NoiseVariable.random()NoiseVariable.rankNoiseVariable.ravel()NoiseVariable.rdot()NoiseVariable.release()NoiseVariable.scramble()NoiseVariable.setValue()NoiseVariable.shapeNoiseVariable.std()NoiseVariable.subscribedVariablesNoiseVariable.sum()NoiseVariable.take()NoiseVariable.tostring()NoiseVariable.unitNoiseVariable.updateOld()NoiseVariable.value
- fipy.variables.operatorVariable module
- fipy.variables.scharfetterGummelFaceVariable module
ScharfetterGummelFaceVariableScharfetterGummelFaceVariable.__abs__()ScharfetterGummelFaceVariable.__add__()ScharfetterGummelFaceVariable.__and__()ScharfetterGummelFaceVariable.__array__()ScharfetterGummelFaceVariable.__array_priority__ScharfetterGummelFaceVariable.__array_wrap__()ScharfetterGummelFaceVariable.__bool__()ScharfetterGummelFaceVariable.__call__()ScharfetterGummelFaceVariable.__div__()ScharfetterGummelFaceVariable.__eq__()ScharfetterGummelFaceVariable.__float__()ScharfetterGummelFaceVariable.__ge__()ScharfetterGummelFaceVariable.__getitem__()ScharfetterGummelFaceVariable.__getstate__()ScharfetterGummelFaceVariable.__gt__()ScharfetterGummelFaceVariable.__hash__()ScharfetterGummelFaceVariable.__int__()ScharfetterGummelFaceVariable.__invert__()ScharfetterGummelFaceVariable.__iter__()ScharfetterGummelFaceVariable.__le__()ScharfetterGummelFaceVariable.__len__()ScharfetterGummelFaceVariable.__lt__()ScharfetterGummelFaceVariable.__mod__()ScharfetterGummelFaceVariable.__mul__()ScharfetterGummelFaceVariable.__ne__()ScharfetterGummelFaceVariable.__neg__()ScharfetterGummelFaceVariable.__new__()ScharfetterGummelFaceVariable.__nonzero__()ScharfetterGummelFaceVariable.__or__()ScharfetterGummelFaceVariable.__pos__()ScharfetterGummelFaceVariable.__pow__()ScharfetterGummelFaceVariable.__radd__()ScharfetterGummelFaceVariable.__rdiv__()ScharfetterGummelFaceVariable.__repr__()ScharfetterGummelFaceVariable.__rmul__()ScharfetterGummelFaceVariable.__rpow__()ScharfetterGummelFaceVariable.__rsub__()ScharfetterGummelFaceVariable.__rtruediv__()ScharfetterGummelFaceVariable.__setitem__()ScharfetterGummelFaceVariable.__setstate__()ScharfetterGummelFaceVariable.__str__()ScharfetterGummelFaceVariable.__sub__()ScharfetterGummelFaceVariable.__truediv__()ScharfetterGummelFaceVariable.all()ScharfetterGummelFaceVariable.allclose()ScharfetterGummelFaceVariable.allequal()ScharfetterGummelFaceVariable.any()ScharfetterGummelFaceVariable.cacheMe()ScharfetterGummelFaceVariable.constrain()ScharfetterGummelFaceVariable.constraintMaskScharfetterGummelFaceVariable.constraintsScharfetterGummelFaceVariable.copy()ScharfetterGummelFaceVariable.divergenceScharfetterGummelFaceVariable.dontCacheMe()ScharfetterGummelFaceVariable.dot()ScharfetterGummelFaceVariable.getsctype()ScharfetterGummelFaceVariable.globalValueScharfetterGummelFaceVariable.inBaseUnits()ScharfetterGummelFaceVariable.inUnitsOf()ScharfetterGummelFaceVariable.itemset()ScharfetterGummelFaceVariable.itemsizeScharfetterGummelFaceVariable.magScharfetterGummelFaceVariable.max()ScharfetterGummelFaceVariable.min()ScharfetterGummelFaceVariable.nameScharfetterGummelFaceVariable.numericValueScharfetterGummelFaceVariable.put()ScharfetterGummelFaceVariable.rankScharfetterGummelFaceVariable.ravel()ScharfetterGummelFaceVariable.rdot()ScharfetterGummelFaceVariable.release()ScharfetterGummelFaceVariable.setValue()ScharfetterGummelFaceVariable.shapeScharfetterGummelFaceVariable.std()ScharfetterGummelFaceVariable.subscribedVariablesScharfetterGummelFaceVariable.sum()ScharfetterGummelFaceVariable.take()ScharfetterGummelFaceVariable.tostring()ScharfetterGummelFaceVariable.unitScharfetterGummelFaceVariable.value
- fipy.variables.surfactantConvectionVariable module
SurfactantConvectionVariableSurfactantConvectionVariable.__abs__()SurfactantConvectionVariable.__add__()SurfactantConvectionVariable.__and__()SurfactantConvectionVariable.__array__()SurfactantConvectionVariable.__array_priority__SurfactantConvectionVariable.__array_wrap__()SurfactantConvectionVariable.__bool__()SurfactantConvectionVariable.__call__()SurfactantConvectionVariable.__div__()SurfactantConvectionVariable.__eq__()SurfactantConvectionVariable.__float__()SurfactantConvectionVariable.__ge__()SurfactantConvectionVariable.__getitem__()SurfactantConvectionVariable.__getstate__()SurfactantConvectionVariable.__gt__()SurfactantConvectionVariable.__hash__()SurfactantConvectionVariable.__int__()SurfactantConvectionVariable.__invert__()SurfactantConvectionVariable.__iter__()SurfactantConvectionVariable.__le__()SurfactantConvectionVariable.__len__()SurfactantConvectionVariable.__lt__()SurfactantConvectionVariable.__mod__()SurfactantConvectionVariable.__mul__()SurfactantConvectionVariable.__ne__()SurfactantConvectionVariable.__neg__()SurfactantConvectionVariable.__new__()SurfactantConvectionVariable.__nonzero__()SurfactantConvectionVariable.__or__()SurfactantConvectionVariable.__pos__()SurfactantConvectionVariable.__pow__()SurfactantConvectionVariable.__radd__()SurfactantConvectionVariable.__rdiv__()SurfactantConvectionVariable.__repr__()SurfactantConvectionVariable.__rmul__()SurfactantConvectionVariable.__rpow__()SurfactantConvectionVariable.__rsub__()SurfactantConvectionVariable.__rtruediv__()SurfactantConvectionVariable.__setitem__()SurfactantConvectionVariable.__setstate__()SurfactantConvectionVariable.__str__()SurfactantConvectionVariable.__sub__()SurfactantConvectionVariable.__truediv__()SurfactantConvectionVariable.all()SurfactantConvectionVariable.allclose()SurfactantConvectionVariable.allequal()SurfactantConvectionVariable.any()SurfactantConvectionVariable.cacheMe()SurfactantConvectionVariable.constrain()SurfactantConvectionVariable.constraintMaskSurfactantConvectionVariable.constraintsSurfactantConvectionVariable.copy()SurfactantConvectionVariable.divergenceSurfactantConvectionVariable.dontCacheMe()SurfactantConvectionVariable.dot()SurfactantConvectionVariable.getsctype()SurfactantConvectionVariable.globalValueSurfactantConvectionVariable.inBaseUnits()SurfactantConvectionVariable.inUnitsOf()SurfactantConvectionVariable.itemset()SurfactantConvectionVariable.itemsizeSurfactantConvectionVariable.magSurfactantConvectionVariable.max()SurfactantConvectionVariable.min()SurfactantConvectionVariable.nameSurfactantConvectionVariable.numericValueSurfactantConvectionVariable.put()SurfactantConvectionVariable.rankSurfactantConvectionVariable.ravel()SurfactantConvectionVariable.rdot()SurfactantConvectionVariable.release()SurfactantConvectionVariable.setValue()SurfactantConvectionVariable.shapeSurfactantConvectionVariable.std()SurfactantConvectionVariable.subscribedVariablesSurfactantConvectionVariable.sum()SurfactantConvectionVariable.take()SurfactantConvectionVariable.tostring()SurfactantConvectionVariable.unitSurfactantConvectionVariable.value
- fipy.variables.surfactantVariable module
SurfactantVariableSurfactantVariable.__abs__()SurfactantVariable.__add__()SurfactantVariable.__and__()SurfactantVariable.__array__()SurfactantVariable.__array_priority__SurfactantVariable.__array_wrap__()SurfactantVariable.__bool__()SurfactantVariable.__call__()SurfactantVariable.__div__()SurfactantVariable.__eq__()SurfactantVariable.__float__()SurfactantVariable.__ge__()SurfactantVariable.__getitem__()SurfactantVariable.__getstate__()SurfactantVariable.__gt__()SurfactantVariable.__hash__()SurfactantVariable.__int__()SurfactantVariable.__invert__()SurfactantVariable.__iter__()SurfactantVariable.__le__()SurfactantVariable.__len__()SurfactantVariable.__lt__()SurfactantVariable.__mod__()SurfactantVariable.__mul__()SurfactantVariable.__ne__()SurfactantVariable.__neg__()SurfactantVariable.__new__()SurfactantVariable.__nonzero__()SurfactantVariable.__or__()SurfactantVariable.__pos__()SurfactantVariable.__pow__()SurfactantVariable.__radd__()SurfactantVariable.__rdiv__()SurfactantVariable.__repr__()SurfactantVariable.__rmul__()SurfactantVariable.__rpow__()SurfactantVariable.__rsub__()SurfactantVariable.__rtruediv__()SurfactantVariable.__setitem__()SurfactantVariable.__setstate__()SurfactantVariable.__str__()SurfactantVariable.__sub__()SurfactantVariable.__truediv__()SurfactantVariable.all()SurfactantVariable.allclose()SurfactantVariable.allequal()SurfactantVariable.any()SurfactantVariable.arithmeticFaceValueSurfactantVariable.cacheMe()SurfactantVariable.cellVolumeAverageSurfactantVariable.constrain()SurfactantVariable.constraintMaskSurfactantVariable.constraintsSurfactantVariable.copy()SurfactantVariable.dontCacheMe()SurfactantVariable.dot()SurfactantVariable.faceGradSurfactantVariable.faceGradAverageSurfactantVariable.faceValueSurfactantVariable.gaussGradSurfactantVariable.getsctype()SurfactantVariable.globalValueSurfactantVariable.gradSurfactantVariable.harmonicFaceValueSurfactantVariable.inBaseUnits()SurfactantVariable.inUnitsOf()SurfactantVariable.interfaceVarSurfactantVariable.itemset()SurfactantVariable.itemsizeSurfactantVariable.leastSquaresGradSurfactantVariable.magSurfactantVariable.max()SurfactantVariable.min()SurfactantVariable.minmodFaceValueSurfactantVariable.nameSurfactantVariable.numericValueSurfactantVariable.oldSurfactantVariable.put()SurfactantVariable.rankSurfactantVariable.ravel()SurfactantVariable.rdot()SurfactantVariable.release()SurfactantVariable.setValue()SurfactantVariable.shapeSurfactantVariable.std()SurfactantVariable.subscribedVariablesSurfactantVariable.sum()SurfactantVariable.take()SurfactantVariable.tostring()SurfactantVariable.unitSurfactantVariable.updateOld()SurfactantVariable.value
- fipy.variables.test module
- fipy.variables.unaryOperatorVariable module
- fipy.variables.uniformNoiseVariable module
UniformNoiseVariableUniformNoiseVariable.__abs__()UniformNoiseVariable.__add__()UniformNoiseVariable.__and__()UniformNoiseVariable.__array__()UniformNoiseVariable.__array_priority__UniformNoiseVariable.__array_wrap__()UniformNoiseVariable.__bool__()UniformNoiseVariable.__call__()UniformNoiseVariable.__div__()UniformNoiseVariable.__eq__()UniformNoiseVariable.__float__()UniformNoiseVariable.__ge__()UniformNoiseVariable.__getitem__()UniformNoiseVariable.__getstate__()UniformNoiseVariable.__gt__()UniformNoiseVariable.__hash__()UniformNoiseVariable.__int__()UniformNoiseVariable.__invert__()UniformNoiseVariable.__iter__()UniformNoiseVariable.__le__()UniformNoiseVariable.__len__()UniformNoiseVariable.__lt__()UniformNoiseVariable.__mod__()UniformNoiseVariable.__mul__()UniformNoiseVariable.__ne__()UniformNoiseVariable.__neg__()UniformNoiseVariable.__new__()UniformNoiseVariable.__nonzero__()UniformNoiseVariable.__or__()UniformNoiseVariable.__pos__()UniformNoiseVariable.__pow__()UniformNoiseVariable.__radd__()UniformNoiseVariable.__rdiv__()UniformNoiseVariable.__repr__()UniformNoiseVariable.__rmul__()UniformNoiseVariable.__rpow__()UniformNoiseVariable.__rsub__()UniformNoiseVariable.__rtruediv__()UniformNoiseVariable.__setitem__()UniformNoiseVariable.__setstate__()UniformNoiseVariable.__str__()UniformNoiseVariable.__sub__()UniformNoiseVariable.__truediv__()UniformNoiseVariable.all()UniformNoiseVariable.allclose()UniformNoiseVariable.allequal()UniformNoiseVariable.any()UniformNoiseVariable.arithmeticFaceValueUniformNoiseVariable.cacheMe()UniformNoiseVariable.cellVolumeAverageUniformNoiseVariable.constrain()UniformNoiseVariable.constraintMaskUniformNoiseVariable.constraintsUniformNoiseVariable.copy()UniformNoiseVariable.dontCacheMe()UniformNoiseVariable.dot()UniformNoiseVariable.faceGradUniformNoiseVariable.faceGradAverageUniformNoiseVariable.faceValueUniformNoiseVariable.gaussGradUniformNoiseVariable.getsctype()UniformNoiseVariable.globalValueUniformNoiseVariable.gradUniformNoiseVariable.harmonicFaceValueUniformNoiseVariable.inBaseUnits()UniformNoiseVariable.inUnitsOf()UniformNoiseVariable.itemset()UniformNoiseVariable.itemsizeUniformNoiseVariable.leastSquaresGradUniformNoiseVariable.magUniformNoiseVariable.max()UniformNoiseVariable.min()UniformNoiseVariable.minmodFaceValueUniformNoiseVariable.nameUniformNoiseVariable.numericValueUniformNoiseVariable.oldUniformNoiseVariable.parallelRandom()UniformNoiseVariable.put()UniformNoiseVariable.random()UniformNoiseVariable.rankUniformNoiseVariable.ravel()UniformNoiseVariable.rdot()UniformNoiseVariable.release()UniformNoiseVariable.scramble()UniformNoiseVariable.setValue()UniformNoiseVariable.shapeUniformNoiseVariable.std()UniformNoiseVariable.subscribedVariablesUniformNoiseVariable.sum()UniformNoiseVariable.take()UniformNoiseVariable.tostring()UniformNoiseVariable.unitUniformNoiseVariable.updateOld()UniformNoiseVariable.value
- fipy.variables.variable module
VariableVariable.__abs__()Variable.__add__()Variable.__and__()Variable.__array__()Variable.__array_priority__Variable.__array_wrap__()Variable.__bool__()Variable.__call__()Variable.__div__()Variable.__eq__()Variable.__float__()Variable.__ge__()Variable.__getitem__()Variable.__getstate__()Variable.__gt__()Variable.__hash__()Variable.__int__()Variable.__invert__()Variable.__iter__()Variable.__le__()Variable.__len__()Variable.__lt__()Variable.__mod__()Variable.__mul__()Variable.__ne__()Variable.__neg__()Variable.__new__()Variable.__nonzero__()Variable.__or__()Variable.__pos__()Variable.__pow__()Variable.__radd__()Variable.__rdiv__()Variable.__repr__()Variable.__rmul__()Variable.__rpow__()Variable.__rsub__()Variable.__rtruediv__()Variable.__setitem__()Variable.__setstate__()Variable.__str__()Variable.__sub__()Variable.__truediv__()Variable.all()Variable.allclose()Variable.allequal()Variable.any()Variable.cacheMe()Variable.constrain()Variable.constraintsVariable.copy()Variable.dontCacheMe()Variable.dot()Variable.getsctype()Variable.inBaseUnits()Variable.inUnitsOf()Variable.itemset()Variable.itemsizeVariable.magVariable.max()Variable.min()Variable.nameVariable.numericValueVariable.put()Variable.ravel()Variable.release()Variable.setValue()Variable.shapeVariable.std()Variable.subscribedVariablesVariable.sum()Variable.take()Variable.tostring()Variable.unitVariable.value
- Module contents
BetaNoiseVariableBetaNoiseVariable.__abs__()BetaNoiseVariable.__add__()BetaNoiseVariable.__and__()BetaNoiseVariable.__array__()BetaNoiseVariable.__array_priority__BetaNoiseVariable.__array_wrap__()BetaNoiseVariable.__bool__()BetaNoiseVariable.__call__()BetaNoiseVariable.__div__()BetaNoiseVariable.__eq__()BetaNoiseVariable.__float__()BetaNoiseVariable.__ge__()BetaNoiseVariable.__getitem__()BetaNoiseVariable.__getstate__()BetaNoiseVariable.__gt__()BetaNoiseVariable.__hash__()BetaNoiseVariable.__int__()BetaNoiseVariable.__invert__()BetaNoiseVariable.__iter__()BetaNoiseVariable.__le__()BetaNoiseVariable.__len__()BetaNoiseVariable.__lt__()BetaNoiseVariable.__mod__()BetaNoiseVariable.__mul__()BetaNoiseVariable.__ne__()BetaNoiseVariable.__neg__()BetaNoiseVariable.__new__()BetaNoiseVariable.__nonzero__()BetaNoiseVariable.__or__()BetaNoiseVariable.__pos__()BetaNoiseVariable.__pow__()BetaNoiseVariable.__radd__()BetaNoiseVariable.__rdiv__()BetaNoiseVariable.__repr__()BetaNoiseVariable.__rmul__()BetaNoiseVariable.__rpow__()BetaNoiseVariable.__rsub__()BetaNoiseVariable.__rtruediv__()BetaNoiseVariable.__setitem__()BetaNoiseVariable.__setstate__()BetaNoiseVariable.__str__()BetaNoiseVariable.__sub__()BetaNoiseVariable.__truediv__()BetaNoiseVariable.all()BetaNoiseVariable.allclose()BetaNoiseVariable.allequal()BetaNoiseVariable.any()BetaNoiseVariable.arithmeticFaceValueBetaNoiseVariable.cacheMe()BetaNoiseVariable.cellVolumeAverageBetaNoiseVariable.constrain()BetaNoiseVariable.constraintMaskBetaNoiseVariable.constraintsBetaNoiseVariable.copy()BetaNoiseVariable.dontCacheMe()BetaNoiseVariable.dot()BetaNoiseVariable.faceGradBetaNoiseVariable.faceGradAverageBetaNoiseVariable.faceValueBetaNoiseVariable.gaussGradBetaNoiseVariable.getsctype()BetaNoiseVariable.globalValueBetaNoiseVariable.gradBetaNoiseVariable.harmonicFaceValueBetaNoiseVariable.inBaseUnits()BetaNoiseVariable.inUnitsOf()BetaNoiseVariable.itemset()BetaNoiseVariable.itemsizeBetaNoiseVariable.leastSquaresGradBetaNoiseVariable.magBetaNoiseVariable.max()BetaNoiseVariable.min()BetaNoiseVariable.minmodFaceValueBetaNoiseVariable.nameBetaNoiseVariable.numericValueBetaNoiseVariable.oldBetaNoiseVariable.parallelRandom()BetaNoiseVariable.put()BetaNoiseVariable.random()BetaNoiseVariable.rankBetaNoiseVariable.ravel()BetaNoiseVariable.rdot()BetaNoiseVariable.release()BetaNoiseVariable.scramble()BetaNoiseVariable.setValue()BetaNoiseVariable.shapeBetaNoiseVariable.std()BetaNoiseVariable.subscribedVariablesBetaNoiseVariable.sum()BetaNoiseVariable.take()BetaNoiseVariable.tostring()BetaNoiseVariable.unitBetaNoiseVariable.updateOld()BetaNoiseVariable.value
CellVariableCellVariable.__abs__()CellVariable.__add__()CellVariable.__and__()CellVariable.__array__()CellVariable.__array_priority__CellVariable.__array_wrap__()CellVariable.__bool__()CellVariable.__call__()CellVariable.__div__()CellVariable.__eq__()CellVariable.__float__()CellVariable.__ge__()CellVariable.__getitem__()CellVariable.__getstate__()CellVariable.__gt__()CellVariable.__hash__()CellVariable.__int__()CellVariable.__invert__()CellVariable.__iter__()CellVariable.__le__()CellVariable.__len__()CellVariable.__lt__()CellVariable.__mod__()CellVariable.__mul__()CellVariable.__ne__()CellVariable.__neg__()CellVariable.__new__()CellVariable.__nonzero__()CellVariable.__or__()CellVariable.__pos__()CellVariable.__pow__()CellVariable.__radd__()CellVariable.__rdiv__()CellVariable.__repr__()CellVariable.__rmul__()CellVariable.__rpow__()CellVariable.__rsub__()CellVariable.__rtruediv__()CellVariable.__setitem__()CellVariable.__setstate__()CellVariable.__str__()CellVariable.__sub__()CellVariable.__truediv__()CellVariable.all()CellVariable.allclose()CellVariable.allequal()CellVariable.any()CellVariable.arithmeticFaceValueCellVariable.cacheMe()CellVariable.cellVolumeAverageCellVariable.constrain()CellVariable.constraintMaskCellVariable.constraintsCellVariable.copy()CellVariable.dontCacheMe()CellVariable.dot()CellVariable.faceGradCellVariable.faceGradAverageCellVariable.faceValueCellVariable.gaussGradCellVariable.getsctype()CellVariable.globalValueCellVariable.gradCellVariable.harmonicFaceValueCellVariable.inBaseUnits()CellVariable.inUnitsOf()CellVariable.itemset()CellVariable.itemsizeCellVariable.leastSquaresGradCellVariable.magCellVariable.max()CellVariable.min()CellVariable.minmodFaceValueCellVariable.nameCellVariable.numericValueCellVariable.oldCellVariable.put()CellVariable.rankCellVariable.ravel()CellVariable.rdot()CellVariable.release()CellVariable.setValue()CellVariable.shapeCellVariable.std()CellVariable.subscribedVariablesCellVariable.sum()CellVariable.take()CellVariable.tostring()CellVariable.unitCellVariable.updateOld()CellVariable.value
DistanceVariableDistanceVariable.__abs__()DistanceVariable.__add__()DistanceVariable.__and__()DistanceVariable.__array__()DistanceVariable.__array_priority__DistanceVariable.__array_wrap__()DistanceVariable.__bool__()DistanceVariable.__call__()DistanceVariable.__div__()DistanceVariable.__eq__()DistanceVariable.__float__()DistanceVariable.__ge__()DistanceVariable.__getitem__()DistanceVariable.__getstate__()DistanceVariable.__gt__()DistanceVariable.__hash__()DistanceVariable.__int__()DistanceVariable.__invert__()DistanceVariable.__iter__()DistanceVariable.__le__()DistanceVariable.__len__()DistanceVariable.__lt__()DistanceVariable.__mod__()DistanceVariable.__mul__()DistanceVariable.__ne__()DistanceVariable.__neg__()DistanceVariable.__new__()DistanceVariable.__nonzero__()DistanceVariable.__or__()DistanceVariable.__pos__()DistanceVariable.__pow__()DistanceVariable.__radd__()DistanceVariable.__rdiv__()DistanceVariable.__repr__()DistanceVariable.__rmul__()DistanceVariable.__rpow__()DistanceVariable.__rsub__()DistanceVariable.__rtruediv__()DistanceVariable.__setitem__()DistanceVariable.__setstate__()DistanceVariable.__str__()DistanceVariable.__sub__()DistanceVariable.__truediv__()DistanceVariable.all()DistanceVariable.allclose()DistanceVariable.allequal()DistanceVariable.any()DistanceVariable.arithmeticFaceValueDistanceVariable.cacheMe()DistanceVariable.calcDistanceFunction()DistanceVariable.cellInterfaceAreasDistanceVariable.cellVolumeAverageDistanceVariable.constrain()DistanceVariable.constraintMaskDistanceVariable.constraintsDistanceVariable.copy()DistanceVariable.dontCacheMe()DistanceVariable.dot()DistanceVariable.extendVariable()DistanceVariable.faceGradDistanceVariable.faceGradAverageDistanceVariable.faceValueDistanceVariable.gaussGradDistanceVariable.getLSMshape()DistanceVariable.getsctype()DistanceVariable.globalValueDistanceVariable.gradDistanceVariable.harmonicFaceValueDistanceVariable.inBaseUnits()DistanceVariable.inUnitsOf()DistanceVariable.itemset()DistanceVariable.itemsizeDistanceVariable.leastSquaresGradDistanceVariable.magDistanceVariable.max()DistanceVariable.min()DistanceVariable.minmodFaceValueDistanceVariable.nameDistanceVariable.numericValueDistanceVariable.oldDistanceVariable.put()DistanceVariable.rankDistanceVariable.ravel()DistanceVariable.rdot()DistanceVariable.release()DistanceVariable.setValue()DistanceVariable.shapeDistanceVariable.std()DistanceVariable.subscribedVariablesDistanceVariable.sum()DistanceVariable.take()DistanceVariable.tostring()DistanceVariable.unitDistanceVariable.updateOld()DistanceVariable.value
ExponentialNoiseVariableExponentialNoiseVariable.__abs__()ExponentialNoiseVariable.__add__()ExponentialNoiseVariable.__and__()ExponentialNoiseVariable.__array__()ExponentialNoiseVariable.__array_priority__ExponentialNoiseVariable.__array_wrap__()ExponentialNoiseVariable.__bool__()ExponentialNoiseVariable.__call__()ExponentialNoiseVariable.__div__()ExponentialNoiseVariable.__eq__()ExponentialNoiseVariable.__float__()ExponentialNoiseVariable.__ge__()ExponentialNoiseVariable.__getitem__()ExponentialNoiseVariable.__getstate__()ExponentialNoiseVariable.__gt__()ExponentialNoiseVariable.__hash__()ExponentialNoiseVariable.__int__()ExponentialNoiseVariable.__invert__()ExponentialNoiseVariable.__iter__()ExponentialNoiseVariable.__le__()ExponentialNoiseVariable.__len__()ExponentialNoiseVariable.__lt__()ExponentialNoiseVariable.__mod__()ExponentialNoiseVariable.__mul__()ExponentialNoiseVariable.__ne__()ExponentialNoiseVariable.__neg__()ExponentialNoiseVariable.__new__()ExponentialNoiseVariable.__nonzero__()ExponentialNoiseVariable.__or__()ExponentialNoiseVariable.__pos__()ExponentialNoiseVariable.__pow__()ExponentialNoiseVariable.__radd__()ExponentialNoiseVariable.__rdiv__()ExponentialNoiseVariable.__repr__()ExponentialNoiseVariable.__rmul__()ExponentialNoiseVariable.__rpow__()ExponentialNoiseVariable.__rsub__()ExponentialNoiseVariable.__rtruediv__()ExponentialNoiseVariable.__setitem__()ExponentialNoiseVariable.__setstate__()ExponentialNoiseVariable.__str__()ExponentialNoiseVariable.__sub__()ExponentialNoiseVariable.__truediv__()ExponentialNoiseVariable.all()ExponentialNoiseVariable.allclose()ExponentialNoiseVariable.allequal()ExponentialNoiseVariable.any()ExponentialNoiseVariable.arithmeticFaceValueExponentialNoiseVariable.cacheMe()ExponentialNoiseVariable.cellVolumeAverageExponentialNoiseVariable.constrain()ExponentialNoiseVariable.constraintMaskExponentialNoiseVariable.constraintsExponentialNoiseVariable.copy()ExponentialNoiseVariable.dontCacheMe()ExponentialNoiseVariable.dot()ExponentialNoiseVariable.faceGradExponentialNoiseVariable.faceGradAverageExponentialNoiseVariable.faceValueExponentialNoiseVariable.gaussGradExponentialNoiseVariable.getsctype()ExponentialNoiseVariable.globalValueExponentialNoiseVariable.gradExponentialNoiseVariable.harmonicFaceValueExponentialNoiseVariable.inBaseUnits()ExponentialNoiseVariable.inUnitsOf()ExponentialNoiseVariable.itemset()ExponentialNoiseVariable.itemsizeExponentialNoiseVariable.leastSquaresGradExponentialNoiseVariable.magExponentialNoiseVariable.max()ExponentialNoiseVariable.min()ExponentialNoiseVariable.minmodFaceValueExponentialNoiseVariable.nameExponentialNoiseVariable.numericValueExponentialNoiseVariable.oldExponentialNoiseVariable.parallelRandom()ExponentialNoiseVariable.put()ExponentialNoiseVariable.random()ExponentialNoiseVariable.rankExponentialNoiseVariable.ravel()ExponentialNoiseVariable.rdot()ExponentialNoiseVariable.release()ExponentialNoiseVariable.scramble()ExponentialNoiseVariable.setValue()ExponentialNoiseVariable.shapeExponentialNoiseVariable.std()ExponentialNoiseVariable.subscribedVariablesExponentialNoiseVariable.sum()ExponentialNoiseVariable.take()ExponentialNoiseVariable.tostring()ExponentialNoiseVariable.unitExponentialNoiseVariable.updateOld()ExponentialNoiseVariable.value
FaceVariableFaceVariable.__abs__()FaceVariable.__add__()FaceVariable.__and__()FaceVariable.__array__()FaceVariable.__array_priority__FaceVariable.__array_wrap__()FaceVariable.__bool__()FaceVariable.__call__()FaceVariable.__div__()FaceVariable.__eq__()FaceVariable.__float__()FaceVariable.__ge__()FaceVariable.__getitem__()FaceVariable.__getstate__()FaceVariable.__gt__()FaceVariable.__hash__()FaceVariable.__int__()FaceVariable.__invert__()FaceVariable.__iter__()FaceVariable.__le__()FaceVariable.__len__()FaceVariable.__lt__()FaceVariable.__mod__()FaceVariable.__mul__()FaceVariable.__ne__()FaceVariable.__neg__()FaceVariable.__new__()FaceVariable.__nonzero__()FaceVariable.__or__()FaceVariable.__pos__()FaceVariable.__pow__()FaceVariable.__radd__()FaceVariable.__rdiv__()FaceVariable.__repr__()FaceVariable.__rmul__()FaceVariable.__rpow__()FaceVariable.__rsub__()FaceVariable.__rtruediv__()FaceVariable.__setitem__()FaceVariable.__setstate__()FaceVariable.__str__()FaceVariable.__sub__()FaceVariable.__truediv__()FaceVariable.all()FaceVariable.allclose()FaceVariable.allequal()FaceVariable.any()FaceVariable.cacheMe()FaceVariable.constrain()FaceVariable.constraintMaskFaceVariable.constraintsFaceVariable.copy()FaceVariable.divergenceFaceVariable.dontCacheMe()FaceVariable.dot()FaceVariable.getsctype()FaceVariable.globalValueFaceVariable.inBaseUnits()FaceVariable.inUnitsOf()FaceVariable.itemset()FaceVariable.itemsizeFaceVariable.magFaceVariable.max()FaceVariable.min()FaceVariable.nameFaceVariable.numericValueFaceVariable.put()FaceVariable.rankFaceVariable.ravel()FaceVariable.rdot()FaceVariable.release()FaceVariable.setValue()FaceVariable.shapeFaceVariable.std()FaceVariable.subscribedVariablesFaceVariable.sum()FaceVariable.take()FaceVariable.tostring()FaceVariable.unitFaceVariable.value
GammaNoiseVariableGammaNoiseVariable.__abs__()GammaNoiseVariable.__add__()GammaNoiseVariable.__and__()GammaNoiseVariable.__array__()GammaNoiseVariable.__array_priority__GammaNoiseVariable.__array_wrap__()GammaNoiseVariable.__bool__()GammaNoiseVariable.__call__()GammaNoiseVariable.__div__()GammaNoiseVariable.__eq__()GammaNoiseVariable.__float__()GammaNoiseVariable.__ge__()GammaNoiseVariable.__getitem__()GammaNoiseVariable.__getstate__()GammaNoiseVariable.__gt__()GammaNoiseVariable.__hash__()GammaNoiseVariable.__int__()GammaNoiseVariable.__invert__()GammaNoiseVariable.__iter__()GammaNoiseVariable.__le__()GammaNoiseVariable.__len__()GammaNoiseVariable.__lt__()GammaNoiseVariable.__mod__()GammaNoiseVariable.__mul__()GammaNoiseVariable.__ne__()GammaNoiseVariable.__neg__()GammaNoiseVariable.__new__()GammaNoiseVariable.__nonzero__()GammaNoiseVariable.__or__()GammaNoiseVariable.__pos__()GammaNoiseVariable.__pow__()GammaNoiseVariable.__radd__()GammaNoiseVariable.__rdiv__()GammaNoiseVariable.__repr__()GammaNoiseVariable.__rmul__()GammaNoiseVariable.__rpow__()GammaNoiseVariable.__rsub__()GammaNoiseVariable.__rtruediv__()GammaNoiseVariable.__setitem__()GammaNoiseVariable.__setstate__()GammaNoiseVariable.__str__()GammaNoiseVariable.__sub__()GammaNoiseVariable.__truediv__()GammaNoiseVariable.all()GammaNoiseVariable.allclose()GammaNoiseVariable.allequal()GammaNoiseVariable.any()GammaNoiseVariable.arithmeticFaceValueGammaNoiseVariable.cacheMe()GammaNoiseVariable.cellVolumeAverageGammaNoiseVariable.constrain()GammaNoiseVariable.constraintMaskGammaNoiseVariable.constraintsGammaNoiseVariable.copy()GammaNoiseVariable.dontCacheMe()GammaNoiseVariable.dot()GammaNoiseVariable.faceGradGammaNoiseVariable.faceGradAverageGammaNoiseVariable.faceValueGammaNoiseVariable.gaussGradGammaNoiseVariable.getsctype()GammaNoiseVariable.globalValueGammaNoiseVariable.gradGammaNoiseVariable.harmonicFaceValueGammaNoiseVariable.inBaseUnits()GammaNoiseVariable.inUnitsOf()GammaNoiseVariable.itemset()GammaNoiseVariable.itemsizeGammaNoiseVariable.leastSquaresGradGammaNoiseVariable.magGammaNoiseVariable.max()GammaNoiseVariable.min()GammaNoiseVariable.minmodFaceValueGammaNoiseVariable.nameGammaNoiseVariable.numericValueGammaNoiseVariable.oldGammaNoiseVariable.parallelRandom()GammaNoiseVariable.put()GammaNoiseVariable.random()GammaNoiseVariable.rankGammaNoiseVariable.ravel()GammaNoiseVariable.rdot()GammaNoiseVariable.release()GammaNoiseVariable.scramble()GammaNoiseVariable.setValue()GammaNoiseVariable.shapeGammaNoiseVariable.std()GammaNoiseVariable.subscribedVariablesGammaNoiseVariable.sum()GammaNoiseVariable.take()GammaNoiseVariable.tostring()GammaNoiseVariable.unitGammaNoiseVariable.updateOld()GammaNoiseVariable.value
GaussianNoiseVariableGaussianNoiseVariable.__abs__()GaussianNoiseVariable.__add__()GaussianNoiseVariable.__and__()GaussianNoiseVariable.__array__()GaussianNoiseVariable.__array_priority__GaussianNoiseVariable.__array_wrap__()GaussianNoiseVariable.__bool__()GaussianNoiseVariable.__call__()GaussianNoiseVariable.__div__()GaussianNoiseVariable.__eq__()GaussianNoiseVariable.__float__()GaussianNoiseVariable.__ge__()GaussianNoiseVariable.__getitem__()GaussianNoiseVariable.__getstate__()GaussianNoiseVariable.__gt__()GaussianNoiseVariable.__hash__()GaussianNoiseVariable.__int__()GaussianNoiseVariable.__invert__()GaussianNoiseVariable.__iter__()GaussianNoiseVariable.__le__()GaussianNoiseVariable.__len__()GaussianNoiseVariable.__lt__()GaussianNoiseVariable.__mod__()GaussianNoiseVariable.__mul__()GaussianNoiseVariable.__ne__()GaussianNoiseVariable.__neg__()GaussianNoiseVariable.__new__()GaussianNoiseVariable.__nonzero__()GaussianNoiseVariable.__or__()GaussianNoiseVariable.__pos__()GaussianNoiseVariable.__pow__()GaussianNoiseVariable.__radd__()GaussianNoiseVariable.__rdiv__()GaussianNoiseVariable.__repr__()GaussianNoiseVariable.__rmul__()GaussianNoiseVariable.__rpow__()GaussianNoiseVariable.__rsub__()GaussianNoiseVariable.__rtruediv__()GaussianNoiseVariable.__setitem__()GaussianNoiseVariable.__setstate__()GaussianNoiseVariable.__str__()GaussianNoiseVariable.__sub__()GaussianNoiseVariable.__truediv__()GaussianNoiseVariable.all()GaussianNoiseVariable.allclose()GaussianNoiseVariable.allequal()GaussianNoiseVariable.any()GaussianNoiseVariable.arithmeticFaceValueGaussianNoiseVariable.cacheMe()GaussianNoiseVariable.cellVolumeAverageGaussianNoiseVariable.constrain()GaussianNoiseVariable.constraintMaskGaussianNoiseVariable.constraintsGaussianNoiseVariable.copy()GaussianNoiseVariable.dontCacheMe()GaussianNoiseVariable.dot()GaussianNoiseVariable.faceGradGaussianNoiseVariable.faceGradAverageGaussianNoiseVariable.faceValueGaussianNoiseVariable.gaussGradGaussianNoiseVariable.getsctype()GaussianNoiseVariable.globalValueGaussianNoiseVariable.gradGaussianNoiseVariable.harmonicFaceValueGaussianNoiseVariable.inBaseUnits()GaussianNoiseVariable.inUnitsOf()GaussianNoiseVariable.itemset()GaussianNoiseVariable.itemsizeGaussianNoiseVariable.leastSquaresGradGaussianNoiseVariable.magGaussianNoiseVariable.max()GaussianNoiseVariable.min()GaussianNoiseVariable.minmodFaceValueGaussianNoiseVariable.nameGaussianNoiseVariable.numericValueGaussianNoiseVariable.oldGaussianNoiseVariable.parallelRandom()GaussianNoiseVariable.put()GaussianNoiseVariable.random()GaussianNoiseVariable.rankGaussianNoiseVariable.ravel()GaussianNoiseVariable.rdot()GaussianNoiseVariable.release()GaussianNoiseVariable.scramble()GaussianNoiseVariable.setValue()GaussianNoiseVariable.shapeGaussianNoiseVariable.std()GaussianNoiseVariable.subscribedVariablesGaussianNoiseVariable.sum()GaussianNoiseVariable.take()GaussianNoiseVariable.tostring()GaussianNoiseVariable.unitGaussianNoiseVariable.updateOld()GaussianNoiseVariable.value
HistogramVariableHistogramVariable.__abs__()HistogramVariable.__add__()HistogramVariable.__and__()HistogramVariable.__array__()HistogramVariable.__array_priority__HistogramVariable.__array_wrap__()HistogramVariable.__bool__()HistogramVariable.__call__()HistogramVariable.__div__()HistogramVariable.__eq__()HistogramVariable.__float__()HistogramVariable.__ge__()HistogramVariable.__getitem__()HistogramVariable.__getstate__()HistogramVariable.__gt__()HistogramVariable.__hash__()HistogramVariable.__int__()HistogramVariable.__invert__()HistogramVariable.__iter__()HistogramVariable.__le__()HistogramVariable.__len__()HistogramVariable.__lt__()HistogramVariable.__mod__()HistogramVariable.__mul__()HistogramVariable.__ne__()HistogramVariable.__neg__()HistogramVariable.__new__()HistogramVariable.__nonzero__()HistogramVariable.__or__()HistogramVariable.__pos__()HistogramVariable.__pow__()HistogramVariable.__radd__()HistogramVariable.__rdiv__()HistogramVariable.__repr__()HistogramVariable.__rmul__()HistogramVariable.__rpow__()HistogramVariable.__rsub__()HistogramVariable.__rtruediv__()HistogramVariable.__setitem__()HistogramVariable.__setstate__()HistogramVariable.__str__()HistogramVariable.__sub__()HistogramVariable.__truediv__()HistogramVariable.all()HistogramVariable.allclose()HistogramVariable.allequal()HistogramVariable.any()HistogramVariable.arithmeticFaceValueHistogramVariable.cacheMe()HistogramVariable.cellVolumeAverageHistogramVariable.constrain()HistogramVariable.constraintMaskHistogramVariable.constraintsHistogramVariable.copy()HistogramVariable.dontCacheMe()HistogramVariable.dot()HistogramVariable.faceGradHistogramVariable.faceGradAverageHistogramVariable.faceValueHistogramVariable.gaussGradHistogramVariable.getsctype()HistogramVariable.globalValueHistogramVariable.gradHistogramVariable.harmonicFaceValueHistogramVariable.inBaseUnits()HistogramVariable.inUnitsOf()HistogramVariable.itemset()HistogramVariable.itemsizeHistogramVariable.leastSquaresGradHistogramVariable.magHistogramVariable.max()HistogramVariable.min()HistogramVariable.minmodFaceValueHistogramVariable.nameHistogramVariable.numericValueHistogramVariable.oldHistogramVariable.put()HistogramVariable.rankHistogramVariable.ravel()HistogramVariable.rdot()HistogramVariable.release()HistogramVariable.setValue()HistogramVariable.shapeHistogramVariable.std()HistogramVariable.subscribedVariablesHistogramVariable.sum()HistogramVariable.take()HistogramVariable.tostring()HistogramVariable.unitHistogramVariable.updateOld()HistogramVariable.value
ModularVariableModularVariable.__abs__()ModularVariable.__add__()ModularVariable.__and__()ModularVariable.__array__()ModularVariable.__array_priority__ModularVariable.__array_wrap__()ModularVariable.__bool__()ModularVariable.__call__()ModularVariable.__div__()ModularVariable.__eq__()ModularVariable.__float__()ModularVariable.__ge__()ModularVariable.__getitem__()ModularVariable.__getstate__()ModularVariable.__gt__()ModularVariable.__hash__()ModularVariable.__int__()ModularVariable.__invert__()ModularVariable.__iter__()ModularVariable.__le__()ModularVariable.__len__()ModularVariable.__lt__()ModularVariable.__mod__()ModularVariable.__mul__()ModularVariable.__ne__()ModularVariable.__neg__()ModularVariable.__new__()ModularVariable.__nonzero__()ModularVariable.__or__()ModularVariable.__pos__()ModularVariable.__pow__()ModularVariable.__radd__()ModularVariable.__rdiv__()ModularVariable.__repr__()ModularVariable.__rmul__()ModularVariable.__rpow__()ModularVariable.__rsub__()ModularVariable.__rtruediv__()ModularVariable.__setitem__()ModularVariable.__setstate__()ModularVariable.__str__()ModularVariable.__sub__()ModularVariable.__truediv__()ModularVariable.all()ModularVariable.allclose()ModularVariable.allequal()ModularVariable.any()ModularVariable.arithmeticFaceValueModularVariable.cacheMe()ModularVariable.cellVolumeAverageModularVariable.constrain()ModularVariable.constraintMaskModularVariable.constraintsModularVariable.copy()ModularVariable.dontCacheMe()ModularVariable.dot()ModularVariable.faceGradModularVariable.faceGradAverageModularVariable.faceGradNoModModularVariable.faceValueModularVariable.gaussGradModularVariable.getsctype()ModularVariable.globalValueModularVariable.gradModularVariable.harmonicFaceValueModularVariable.inBaseUnits()ModularVariable.inUnitsOf()ModularVariable.itemset()ModularVariable.itemsizeModularVariable.leastSquaresGradModularVariable.magModularVariable.max()ModularVariable.min()ModularVariable.minmodFaceValueModularVariable.nameModularVariable.numericValueModularVariable.oldModularVariable.put()ModularVariable.rankModularVariable.ravel()ModularVariable.rdot()ModularVariable.release()ModularVariable.setValue()ModularVariable.shapeModularVariable.std()ModularVariable.subscribedVariablesModularVariable.sum()ModularVariable.take()ModularVariable.tostring()ModularVariable.unitModularVariable.updateOld()ModularVariable.value
ScharfetterGummelFaceVariableScharfetterGummelFaceVariable.__abs__()ScharfetterGummelFaceVariable.__add__()ScharfetterGummelFaceVariable.__and__()ScharfetterGummelFaceVariable.__array__()ScharfetterGummelFaceVariable.__array_priority__ScharfetterGummelFaceVariable.__array_wrap__()ScharfetterGummelFaceVariable.__bool__()ScharfetterGummelFaceVariable.__call__()ScharfetterGummelFaceVariable.__div__()ScharfetterGummelFaceVariable.__eq__()ScharfetterGummelFaceVariable.__float__()ScharfetterGummelFaceVariable.__ge__()ScharfetterGummelFaceVariable.__getitem__()ScharfetterGummelFaceVariable.__getstate__()ScharfetterGummelFaceVariable.__gt__()ScharfetterGummelFaceVariable.__hash__()ScharfetterGummelFaceVariable.__int__()ScharfetterGummelFaceVariable.__invert__()ScharfetterGummelFaceVariable.__iter__()ScharfetterGummelFaceVariable.__le__()ScharfetterGummelFaceVariable.__len__()ScharfetterGummelFaceVariable.__lt__()ScharfetterGummelFaceVariable.__mod__()ScharfetterGummelFaceVariable.__mul__()ScharfetterGummelFaceVariable.__ne__()ScharfetterGummelFaceVariable.__neg__()ScharfetterGummelFaceVariable.__new__()ScharfetterGummelFaceVariable.__nonzero__()ScharfetterGummelFaceVariable.__or__()ScharfetterGummelFaceVariable.__pos__()ScharfetterGummelFaceVariable.__pow__()ScharfetterGummelFaceVariable.__radd__()ScharfetterGummelFaceVariable.__rdiv__()ScharfetterGummelFaceVariable.__repr__()ScharfetterGummelFaceVariable.__rmul__()ScharfetterGummelFaceVariable.__rpow__()ScharfetterGummelFaceVariable.__rsub__()ScharfetterGummelFaceVariable.__rtruediv__()ScharfetterGummelFaceVariable.__setitem__()ScharfetterGummelFaceVariable.__setstate__()ScharfetterGummelFaceVariable.__str__()ScharfetterGummelFaceVariable.__sub__()ScharfetterGummelFaceVariable.__truediv__()ScharfetterGummelFaceVariable.all()ScharfetterGummelFaceVariable.allclose()ScharfetterGummelFaceVariable.allequal()ScharfetterGummelFaceVariable.any()ScharfetterGummelFaceVariable.cacheMe()ScharfetterGummelFaceVariable.constrain()ScharfetterGummelFaceVariable.constraintMaskScharfetterGummelFaceVariable.constraintsScharfetterGummelFaceVariable.copy()ScharfetterGummelFaceVariable.divergenceScharfetterGummelFaceVariable.dontCacheMe()ScharfetterGummelFaceVariable.dot()ScharfetterGummelFaceVariable.getsctype()ScharfetterGummelFaceVariable.globalValueScharfetterGummelFaceVariable.inBaseUnits()ScharfetterGummelFaceVariable.inUnitsOf()ScharfetterGummelFaceVariable.itemset()ScharfetterGummelFaceVariable.itemsizeScharfetterGummelFaceVariable.magScharfetterGummelFaceVariable.max()ScharfetterGummelFaceVariable.min()ScharfetterGummelFaceVariable.nameScharfetterGummelFaceVariable.numericValueScharfetterGummelFaceVariable.put()ScharfetterGummelFaceVariable.rankScharfetterGummelFaceVariable.ravel()ScharfetterGummelFaceVariable.rdot()ScharfetterGummelFaceVariable.release()ScharfetterGummelFaceVariable.setValue()ScharfetterGummelFaceVariable.shapeScharfetterGummelFaceVariable.std()ScharfetterGummelFaceVariable.subscribedVariablesScharfetterGummelFaceVariable.sum()ScharfetterGummelFaceVariable.take()ScharfetterGummelFaceVariable.tostring()ScharfetterGummelFaceVariable.unitScharfetterGummelFaceVariable.value
SurfactantConvectionVariableSurfactantConvectionVariable.__abs__()SurfactantConvectionVariable.__add__()SurfactantConvectionVariable.__and__()SurfactantConvectionVariable.__array__()SurfactantConvectionVariable.__array_priority__SurfactantConvectionVariable.__array_wrap__()SurfactantConvectionVariable.__bool__()SurfactantConvectionVariable.__call__()SurfactantConvectionVariable.__div__()SurfactantConvectionVariable.__eq__()SurfactantConvectionVariable.__float__()SurfactantConvectionVariable.__ge__()SurfactantConvectionVariable.__getitem__()SurfactantConvectionVariable.__getstate__()SurfactantConvectionVariable.__gt__()SurfactantConvectionVariable.__hash__()SurfactantConvectionVariable.__int__()SurfactantConvectionVariable.__invert__()SurfactantConvectionVariable.__iter__()SurfactantConvectionVariable.__le__()SurfactantConvectionVariable.__len__()SurfactantConvectionVariable.__lt__()SurfactantConvectionVariable.__mod__()SurfactantConvectionVariable.__mul__()SurfactantConvectionVariable.__ne__()SurfactantConvectionVariable.__neg__()SurfactantConvectionVariable.__new__()SurfactantConvectionVariable.__nonzero__()SurfactantConvectionVariable.__or__()SurfactantConvectionVariable.__pos__()SurfactantConvectionVariable.__pow__()SurfactantConvectionVariable.__radd__()SurfactantConvectionVariable.__rdiv__()SurfactantConvectionVariable.__repr__()SurfactantConvectionVariable.__rmul__()SurfactantConvectionVariable.__rpow__()SurfactantConvectionVariable.__rsub__()SurfactantConvectionVariable.__rtruediv__()SurfactantConvectionVariable.__setitem__()SurfactantConvectionVariable.__setstate__()SurfactantConvectionVariable.__str__()SurfactantConvectionVariable.__sub__()SurfactantConvectionVariable.__truediv__()SurfactantConvectionVariable.all()SurfactantConvectionVariable.allclose()SurfactantConvectionVariable.allequal()SurfactantConvectionVariable.any()SurfactantConvectionVariable.cacheMe()SurfactantConvectionVariable.constrain()SurfactantConvectionVariable.constraintMaskSurfactantConvectionVariable.constraintsSurfactantConvectionVariable.copy()SurfactantConvectionVariable.divergenceSurfactantConvectionVariable.dontCacheMe()SurfactantConvectionVariable.dot()SurfactantConvectionVariable.getsctype()SurfactantConvectionVariable.globalValueSurfactantConvectionVariable.inBaseUnits()SurfactantConvectionVariable.inUnitsOf()SurfactantConvectionVariable.itemset()SurfactantConvectionVariable.itemsizeSurfactantConvectionVariable.magSurfactantConvectionVariable.max()SurfactantConvectionVariable.min()SurfactantConvectionVariable.nameSurfactantConvectionVariable.numericValueSurfactantConvectionVariable.put()SurfactantConvectionVariable.rankSurfactantConvectionVariable.ravel()SurfactantConvectionVariable.rdot()SurfactantConvectionVariable.release()SurfactantConvectionVariable.setValue()SurfactantConvectionVariable.shapeSurfactantConvectionVariable.std()SurfactantConvectionVariable.subscribedVariablesSurfactantConvectionVariable.sum()SurfactantConvectionVariable.take()SurfactantConvectionVariable.tostring()SurfactantConvectionVariable.unitSurfactantConvectionVariable.value
SurfactantVariableSurfactantVariable.__abs__()SurfactantVariable.__add__()SurfactantVariable.__and__()SurfactantVariable.__array__()SurfactantVariable.__array_priority__SurfactantVariable.__array_wrap__()SurfactantVariable.__bool__()SurfactantVariable.__call__()SurfactantVariable.__div__()SurfactantVariable.__eq__()SurfactantVariable.__float__()SurfactantVariable.__ge__()SurfactantVariable.__getitem__()SurfactantVariable.__getstate__()SurfactantVariable.__gt__()SurfactantVariable.__hash__()SurfactantVariable.__int__()SurfactantVariable.__invert__()SurfactantVariable.__iter__()SurfactantVariable.__le__()SurfactantVariable.__len__()SurfactantVariable.__lt__()SurfactantVariable.__mod__()SurfactantVariable.__mul__()SurfactantVariable.__ne__()SurfactantVariable.__neg__()SurfactantVariable.__new__()SurfactantVariable.__nonzero__()SurfactantVariable.__or__()SurfactantVariable.__pos__()SurfactantVariable.__pow__()SurfactantVariable.__radd__()SurfactantVariable.__rdiv__()SurfactantVariable.__repr__()SurfactantVariable.__rmul__()SurfactantVariable.__rpow__()SurfactantVariable.__rsub__()SurfactantVariable.__rtruediv__()SurfactantVariable.__setitem__()SurfactantVariable.__setstate__()SurfactantVariable.__str__()SurfactantVariable.__sub__()SurfactantVariable.__truediv__()SurfactantVariable.all()SurfactantVariable.allclose()SurfactantVariable.allequal()SurfactantVariable.any()SurfactantVariable.arithmeticFaceValueSurfactantVariable.cacheMe()SurfactantVariable.cellVolumeAverageSurfactantVariable.constrain()SurfactantVariable.constraintMaskSurfactantVariable.constraintsSurfactantVariable.copy()SurfactantVariable.dontCacheMe()SurfactantVariable.dot()SurfactantVariable.faceGradSurfactantVariable.faceGradAverageSurfactantVariable.faceValueSurfactantVariable.gaussGradSurfactantVariable.getsctype()SurfactantVariable.globalValueSurfactantVariable.gradSurfactantVariable.harmonicFaceValueSurfactantVariable.inBaseUnits()SurfactantVariable.inUnitsOf()SurfactantVariable.interfaceVarSurfactantVariable.itemset()SurfactantVariable.itemsizeSurfactantVariable.leastSquaresGradSurfactantVariable.magSurfactantVariable.max()SurfactantVariable.min()SurfactantVariable.minmodFaceValueSurfactantVariable.nameSurfactantVariable.numericValueSurfactantVariable.oldSurfactantVariable.put()SurfactantVariable.rankSurfactantVariable.ravel()SurfactantVariable.rdot()SurfactantVariable.release()SurfactantVariable.setValue()SurfactantVariable.shapeSurfactantVariable.std()SurfactantVariable.subscribedVariablesSurfactantVariable.sum()SurfactantVariable.take()SurfactantVariable.tostring()SurfactantVariable.unitSurfactantVariable.updateOld()SurfactantVariable.value
UniformNoiseVariableUniformNoiseVariable.__abs__()UniformNoiseVariable.__add__()UniformNoiseVariable.__and__()UniformNoiseVariable.__array__()UniformNoiseVariable.__array_priority__UniformNoiseVariable.__array_wrap__()UniformNoiseVariable.__bool__()UniformNoiseVariable.__call__()UniformNoiseVariable.__div__()UniformNoiseVariable.__eq__()UniformNoiseVariable.__float__()UniformNoiseVariable.__ge__()UniformNoiseVariable.__getitem__()UniformNoiseVariable.__getstate__()UniformNoiseVariable.__gt__()UniformNoiseVariable.__hash__()UniformNoiseVariable.__int__()UniformNoiseVariable.__invert__()UniformNoiseVariable.__iter__()UniformNoiseVariable.__le__()UniformNoiseVariable.__len__()UniformNoiseVariable.__lt__()UniformNoiseVariable.__mod__()UniformNoiseVariable.__mul__()UniformNoiseVariable.__ne__()UniformNoiseVariable.__neg__()UniformNoiseVariable.__new__()UniformNoiseVariable.__nonzero__()UniformNoiseVariable.__or__()UniformNoiseVariable.__pos__()UniformNoiseVariable.__pow__()UniformNoiseVariable.__radd__()UniformNoiseVariable.__rdiv__()UniformNoiseVariable.__repr__()UniformNoiseVariable.__rmul__()UniformNoiseVariable.__rpow__()UniformNoiseVariable.__rsub__()UniformNoiseVariable.__rtruediv__()UniformNoiseVariable.__setitem__()UniformNoiseVariable.__setstate__()UniformNoiseVariable.__str__()UniformNoiseVariable.__sub__()UniformNoiseVariable.__truediv__()UniformNoiseVariable.all()UniformNoiseVariable.allclose()UniformNoiseVariable.allequal()UniformNoiseVariable.any()UniformNoiseVariable.arithmeticFaceValueUniformNoiseVariable.cacheMe()UniformNoiseVariable.cellVolumeAverageUniformNoiseVariable.constrain()UniformNoiseVariable.constraintMaskUniformNoiseVariable.constraintsUniformNoiseVariable.copy()UniformNoiseVariable.dontCacheMe()UniformNoiseVariable.dot()UniformNoiseVariable.faceGradUniformNoiseVariable.faceGradAverageUniformNoiseVariable.faceValueUniformNoiseVariable.gaussGradUniformNoiseVariable.getsctype()UniformNoiseVariable.globalValueUniformNoiseVariable.gradUniformNoiseVariable.harmonicFaceValueUniformNoiseVariable.inBaseUnits()UniformNoiseVariable.inUnitsOf()UniformNoiseVariable.itemset()UniformNoiseVariable.itemsizeUniformNoiseVariable.leastSquaresGradUniformNoiseVariable.magUniformNoiseVariable.max()UniformNoiseVariable.min()UniformNoiseVariable.minmodFaceValueUniformNoiseVariable.nameUniformNoiseVariable.numericValueUniformNoiseVariable.oldUniformNoiseVariable.parallelRandom()UniformNoiseVariable.put()UniformNoiseVariable.random()UniformNoiseVariable.rankUniformNoiseVariable.ravel()UniformNoiseVariable.rdot()UniformNoiseVariable.release()UniformNoiseVariable.scramble()UniformNoiseVariable.setValue()UniformNoiseVariable.shapeUniformNoiseVariable.std()UniformNoiseVariable.subscribedVariablesUniformNoiseVariable.sum()UniformNoiseVariable.take()UniformNoiseVariable.tostring()UniformNoiseVariable.unitUniformNoiseVariable.updateOld()UniformNoiseVariable.value
VariableVariable.__abs__()Variable.__add__()Variable.__and__()Variable.__array__()Variable.__array_priority__Variable.__array_wrap__()Variable.__bool__()Variable.__call__()Variable.__div__()Variable.__eq__()Variable.__float__()Variable.__ge__()Variable.__getitem__()Variable.__getstate__()Variable.__gt__()Variable.__hash__()Variable.__int__()Variable.__invert__()Variable.__iter__()Variable.__le__()Variable.__len__()Variable.__lt__()Variable.__mod__()Variable.__mul__()Variable.__ne__()Variable.__neg__()Variable.__new__()Variable.__nonzero__()Variable.__or__()Variable.__pos__()Variable.__pow__()Variable.__radd__()Variable.__rdiv__()Variable.__repr__()Variable.__rmul__()Variable.__rpow__()Variable.__rsub__()Variable.__rtruediv__()Variable.__setitem__()Variable.__setstate__()Variable.__str__()Variable.__sub__()Variable.__truediv__()Variable.all()Variable.allclose()Variable.allequal()Variable.any()Variable.cacheMe()Variable.constrain()Variable.constraintsVariable.copy()Variable.dontCacheMe()Variable.dot()Variable.getsctype()Variable.inBaseUnits()Variable.inUnitsOf()Variable.itemset()Variable.itemsizeVariable.magVariable.max()Variable.min()Variable.nameVariable.numericValueVariable.put()Variable.ravel()Variable.release()Variable.setValue()Variable.shapeVariable.std()Variable.subscribedVariablesVariable.sum()Variable.take()Variable.tostring()Variable.unitVariable.value
- fipy.viewers package
- Subpackages
- fipy.viewers.matplotlibViewer package
- Submodules
- fipy.viewers.matplotlibViewer.matplotlib1DViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DContourViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DGridContourViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DGridViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DViewer module
- fipy.viewers.matplotlibViewer.matplotlibSparseMatrixViewer module
- fipy.viewers.matplotlibViewer.matplotlibStreamViewer module
- fipy.viewers.matplotlibViewer.matplotlibVectorViewer module
- fipy.viewers.matplotlibViewer.matplotlibViewer module
- fipy.viewers.matplotlibViewer.test module
- Module contents
- fipy.viewers.mayaviViewer package
- fipy.viewers.vtkViewer package
- fipy.viewers.matplotlibViewer package
- Submodules
- fipy.viewers.multiViewer module
- fipy.viewers.test module
- fipy.viewers.testinteractive module
- fipy.viewers.tsvViewer module
- fipy.viewers.viewer module
- Module contents
DummyViewerMatplotlib1DViewerMatplotlib1DViewer.axesMatplotlib1DViewer.cmapMatplotlib1DViewer.colorbarMatplotlib1DViewer.figMatplotlib1DViewer.figaspect()Matplotlib1DViewer.idMatplotlib1DViewer.limitsMatplotlib1DViewer.linesMatplotlib1DViewer.logMatplotlib1DViewer.plot()Matplotlib1DViewer.plotMesh()Matplotlib1DViewer.setLimits()Matplotlib1DViewer.titleMatplotlib1DViewer.vars
Matplotlib2DContourViewerMatplotlib2DContourViewer.axesMatplotlib2DContourViewer.cmapMatplotlib2DContourViewer.colorbarMatplotlib2DContourViewer.figMatplotlib2DContourViewer.figaspect()Matplotlib2DContourViewer.idMatplotlib2DContourViewer.levelsMatplotlib2DContourViewer.limitsMatplotlib2DContourViewer.logMatplotlib2DContourViewer.plot()Matplotlib2DContourViewer.plotMesh()Matplotlib2DContourViewer.setLimits()Matplotlib2DContourViewer.titleMatplotlib2DContourViewer.vars
Matplotlib2DGridContourViewerMatplotlib2DGridContourViewer.axesMatplotlib2DGridContourViewer.cmapMatplotlib2DGridContourViewer.colorbarMatplotlib2DGridContourViewer.figMatplotlib2DGridContourViewer.figaspect()Matplotlib2DGridContourViewer.idMatplotlib2DGridContourViewer.levelsMatplotlib2DGridContourViewer.limitsMatplotlib2DGridContourViewer.logMatplotlib2DGridContourViewer.plot()Matplotlib2DGridContourViewer.plotMesh()Matplotlib2DGridContourViewer.setLimits()Matplotlib2DGridContourViewer.titleMatplotlib2DGridContourViewer.vars
Matplotlib2DGridViewerMatplotlib2DGridViewer.axesMatplotlib2DGridViewer.cmapMatplotlib2DGridViewer.colorbarMatplotlib2DGridViewer.figMatplotlib2DGridViewer.figaspect()Matplotlib2DGridViewer.idMatplotlib2DGridViewer.limitsMatplotlib2DGridViewer.logMatplotlib2DGridViewer.plot()Matplotlib2DGridViewer.plotMesh()Matplotlib2DGridViewer.setLimits()Matplotlib2DGridViewer.titleMatplotlib2DGridViewer.vars
Matplotlib2DViewerMatplotlib2DViewer.axesMatplotlib2DViewer.cmapMatplotlib2DViewer.collectionMatplotlib2DViewer.colorbarMatplotlib2DViewer.figMatplotlib2DViewer.figaspect()Matplotlib2DViewer.idMatplotlib2DViewer.limitsMatplotlib2DViewer.logMatplotlib2DViewer.plot()Matplotlib2DViewer.plotMesh()Matplotlib2DViewer.setLimits()Matplotlib2DViewer.titleMatplotlib2DViewer.vars
MatplotlibStreamViewerMatplotlibStreamViewer.axesMatplotlibStreamViewer.cmapMatplotlibStreamViewer.colorbarMatplotlibStreamViewer.figMatplotlibStreamViewer.figaspect()MatplotlibStreamViewer.idMatplotlibStreamViewer.kwargsMatplotlibStreamViewer.limitsMatplotlibStreamViewer.logMatplotlibStreamViewer.plot()MatplotlibStreamViewer.plotMesh()MatplotlibStreamViewer.setLimits()MatplotlibStreamViewer.titleMatplotlibStreamViewer.vars
MatplotlibVectorViewerMatplotlibVectorViewer.axesMatplotlibVectorViewer.cmapMatplotlibVectorViewer.colorbarMatplotlibVectorViewer.figMatplotlibVectorViewer.figaspect()MatplotlibVectorViewer.idMatplotlibVectorViewer.limitsMatplotlibVectorViewer.logMatplotlibVectorViewer.plot()MatplotlibVectorViewer.plotMesh()MatplotlibVectorViewer.quiver()MatplotlibVectorViewer.setLimits()MatplotlibVectorViewer.titleMatplotlibVectorViewer.vars
MatplotlibViewer()MayaviClientMeshDimensionErrorMeshDimensionError.__cause__MeshDimensionError.__context__MeshDimensionError.__delattr__()MeshDimensionError.__getattribute__()MeshDimensionError.__reduce__()MeshDimensionError.__repr__()MeshDimensionError.__setattr__()MeshDimensionError.__setstate__()MeshDimensionError.__str__()MeshDimensionError.__suppress_context__MeshDimensionError.__traceback__MeshDimensionError.argsMeshDimensionError.with_traceback()
MultiViewerTSVViewerVTKCellViewerVTKFaceViewerVTKViewer()Viewer()
- Subpackages
Submodules¶
fipy.testFiPy module¶
Module contents¶
FiPy is an object oriented, partial differential equation (PDE) solver, written in Python, based on a standard finite volume (FV) approach. The framework has been developed in the Materials Science and Engineering Division (MSED) and Center for Theoretical and Computational Materials Science (CTCMS), in the Material Measurement Laboratory (MML) at the National Institute of Standards and Technology (NIST).
The solution of coupled sets of PDEs is ubiquitous to the numerical simulation of science problems. Numerous PDE solvers exist, using a variety of languages and numerical approaches. Many are proprietary, expensive and difficult to customize. As a result, scientists spend considerable resources repeatedly developing limited tools for specific problems. Our approach, combining the FV method and Python, provides a tool that is extensible, powerful and freely available. A significant advantage to Python is the existing suite of tools for array calculations, sparse matrices and data rendering.
The FiPy framework includes terms for transient diffusion, convection and standard sources, enabling the solution of arbitrary combinations of coupled elliptic, hyperbolic and parabolic PDEs. Currently implemented models include phase field [1] [2] [3] treatments of polycrystalline, dendritic, and electrochemical phase transformations, as well as drug eluting stents [4], reactive wetting [5], photovoltaics [6] and a level set treatment of the electrodeposition process [7].
- exception fipy.AbstractBaseClassError(s="can't instantiate abstract base class")¶
Bases:
NotImplementedError- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.AdvectionTerm(coeff=None)¶
Bases:
FirstOrderAdvectionTermThe AdvectionTerm object constructs the b vector contribution for the advection term given by
\[u \abs{\nabla \phi}\]from the advection equation given by:
\[\frac{\partial \phi}{\partial t} + u \abs{\nabla \phi} = 0\]The construction of the gradient magnitude term requires upwinding as in the standard FirstOrderAdvectionTerm. The higher order terms are incorporated as follows. The formula used here is given by:
\[u_P \abs{\nabla \phi}_P = \max \left( u_P , 0 \right) \left[ \sum_A \min \left( D_{AP}, 0 \right)^2 \right]^{1/2} + \min \left( u_P , 0 \right) \left[ \sum_A \max \left( D_{AP}, 0 \right)^2 \right]^{1/2}\]where,
\[D_{AP} = \frac{ \phi_A - \phi_P } { d_{AP}} - \frac{ d_{AP} } {2} m \left(L_A, L_P \right)\]and
\[\begin{split}m\left(x, y\right) &= x \qquad \text{if $\abs{x} \le \abs{y} \forall xy \ge 0$} \\ m\left(x, y\right) &= y \qquad \text{if $\abs{x} > \abs{y} \forall xy \ge 0$} \\ m\left(x, y\right) &= 0 \qquad \text{if $xy < 0$}\end{split}\]also,
\[\begin{split}L_A &= \frac{\phi_{AA} + \phi_P - 2 \phi_A}{d_{AP}^2} \\ L_P &= \frac{\phi_{A} + \phi_{PP} - 2 \phi_P}{d_{AP}^2}\end{split}\]Here are some simple test cases for this problem:
>>> from fipy.meshes import Grid1D >>> from fipy.solvers import * >>> SparseMatrix = LinearPCGSolver()._matrixClass >>> mesh = Grid1D(dx = 1., nx = 3)
Trivial test:
>>> from fipy.variables.cellVariable import CellVariable >>> coeff = CellVariable(mesh = mesh, value = numerix.zeros(3, 'd')) >>> v, L, b = AdvectionTerm(0.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.zeros(3, 'd'), atol = 1e-10)) True
Less trivial test:
>>> coeff = CellVariable(mesh = mesh, value = numerix.arange(3)) >>> v, L, b = AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((0., -1., -1.)), atol = 1e-10)) True
Even less trivial
>>> coeff = CellVariable(mesh = mesh, value = numerix.arange(3)) >>> v, L, b = AdvectionTerm(-1.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((1., 1., 0.)), atol = 1e-10)) True
Another trivial test case (more trivial than a trivial test case standing on a harpsichord singing “trivial test cases are here again”)
>>> vel = numerix.array((-1, 2, -3)) >>> coeff = CellVariable(mesh = mesh, value = numerix.array((4, 6, 1))) >>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, -vel * numerix.array((2, numerix.sqrt(5**2 + 2**2), 5)), atol = 1e-10)) True
Somewhat less trivial test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2) >>> vel = numerix.array((3, -5, -6, -3)) >>> coeff = CellVariable(mesh = mesh, value = numerix.array((3, 1, 6, 7))) >>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> answer = -vel * numerix.array((2, numerix.sqrt(2**2 + 6**2), 1, 0)) >>> print(numerix.allclose(b, answer, atol = 1e-10)) True
For the above test cases the AdvectionTerm gives the same result as the AdvectionTerm. The following test imposes a quadratic field. The higher order term can resolve this field correctly.
\[\phi = x^2\]The returned vector
bshould have the value:\[-\abs{\nabla \phi} = -\left|\frac{\partial \phi}{\partial x}\right| = - 2 \abs{x}\]Build the test case in the following way,
>>> mesh = Grid1D(dx = 1., nx = 5) >>> vel = 1. >>> coeff = CellVariable(mesh = mesh, value = mesh.cellCenters[0]**2) >>> v, L, b = __AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix)
The first order term is not accurate. The first and last element are ignored because they don’t have any neighbors for higher order evaluation
>>> print(numerix.allclose(CellVariable(mesh=mesh, ... value=b).globalValue[1:-1], -2 * mesh.cellCenters.globalValue[0][1:-1])) False
The higher order term is spot on.
>>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(CellVariable(mesh=mesh, ... value=b).globalValue[1:-1], -2 * mesh.cellCenters.globalValue[0][1:-1])) True
The AdvectionTerm will also resolve a circular field with more accuracy,
\[\phi = \left( x^2 + y^2 \right)^{1/2}\]Build the test case in the following way,
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 10, ny = 10) >>> vel = 1. >>> x, y = mesh.cellCenters >>> r = numerix.sqrt(x**2 + y**2) >>> coeff = CellVariable(mesh = mesh, value = r) >>> v, L, b = __AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> error = CellVariable(mesh=mesh, value=b + 1) >>> ans = CellVariable(mesh=mesh, value=b + 1) >>> ans[(x > 2) & (x < 8) & (y > 2) & (y < 8)] = 0.123105625618 >>> print((error <= ans).all()) True
The maximum error is large (about 12 %) for the first order advection.
>>> v, L, b = AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> error = CellVariable(mesh=mesh, value=b + 1) >>> ans = CellVariable(mesh=mesh, value=b + 1) >>> ans[(x > 2) & (x < 8) & (y > 2) & (y < 8)] = 0.0201715476598 >>> print((error <= ans).all()) True
The maximum error is 2 % when using a higher order contribution.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.BetaNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariableRepresents a beta distribution of random numbers with the probability distribution
\[x^{\alpha - 1}\frac{\beta^\alpha e^{-\beta x}}{\Gamma(\alpha)}\]with a shape parameter \(\alpha\), a rate parameter \(\beta\), and \(\Gamma(z) = \int_0^\infty t^{z - 1}e^{-t}\,dt\).
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> alpha = Variable() >>> beta = Variable() >>> from fipy.meshes import Grid2D >>> noise = BetaNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), alpha = alpha, beta = beta)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.01, nx = 100)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> betadist = CellVariable(mesh = histogram.mesh) >>> x = CellVariable(mesh=histogram.mesh, value=histogram.mesh.cellCenters[0]) >>> from scipy.special import gamma as Gamma >>> betadist = ((Gamma(alpha + beta) / (Gamma(alpha) * Gamma(beta))) ... * x**(alpha - 1) * (1 - x)**(beta - 1))
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=1) ... histoplot = Viewer(vars=(histogram, betadist), ... datamin=0, datamax=1.5)
>>> from fipy.tools.numerix import arange
>>> for a in arange(0.5, 5, 0.5): ... alpha.value = a ... for b in arange(0.5, 5, 0.5): ... beta.value = b ... if __name__ == '__main__': ... import sys ... print("alpha: %g, beta: %g" % (alpha, beta), file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.CellVariable(*args, **kwds)¶
Bases:
_MeshVariableRepresents the field of values of a variable on a Mesh.
A CellVariable can be
pickledto persistent storage (disk) for later use:>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 10, ny = 10)
>>> var = CellVariable(mesh = mesh, value = 1., hasOld = 1, name = 'test') >>> x, y = mesh.cellCenters >>> var.value = (x * y)
>>> from fipy.tools import dump >>> (f, filename) = dump.write(var, extension = '.gz') >>> unPickledVar = dump.read(filename, f)
>>> print(var.allclose(unPickledVar, atol = 1e-10, rtol = 1e-10)) 1
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tupleofint) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.CentralDifferenceConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractConvectionTermThis
Termrepresents\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P +(1-\alpha_f)\phi_A\) and \(\alpha_f\) is calculated using the central differencing scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.Constraint(value, where=None)¶
Bases:
objectObject to hold a Variable to value at where
see
constrain()- __repr__()¶
Return repr(self).
- fipy.ConvectionTerm¶
alias of
PowerLawConvectionTerm
- fipy.CylindricalGrid1D(dr=None, nr=None, Lr=None, dx=1.0, nx=None, Lx=None, origin=(0,), overlap=2, communicator=DummyComm())¶
Create a 2D cylindrical mesh
Factory function to select between
CylindricalUniformGrid1DandCylindricalNonUniformGrid1D. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
nr (int) – Number of cells in the radial direction. Alternative: nx.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- fipy.CylindricalGrid2D(dr=None, dz=None, nr=None, nz=None, Lr=None, Lz=None, dx=1.0, dy=1.0, nx=None, ny=None, Lx=None, Ly=None, origin=((0,), (0,)), overlap=2, communicator=DummyComm())¶
Create a 2D cylindrical mesh
Factory function to select between
CylindricalUniformGrid2DandCylindricalNonUniformGrid2D. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
dz (float) – grid spacing in the vertical direction. Alternative: dy.
nr (int) – Number of cells in the radial direction. Alternative: nx.
nz (int) – Number of cells in the vertical direction. Alternative: ny.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
Lz (float) – Domain length in the vertical direction. Alternative: Ly.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- fipy.DefaultAsymmetricSolver¶
alias of
LinearLUSolver
- fipy.DefaultSolver¶
alias of
LinearLUSolver
- class fipy.DiffusionTerm(coeff=(1.0,), var=None)¶
Bases:
DiffusionTermNoCorrectionThis term represents a higher order diffusion term. The order of the term is determined by the number of coeffs, such that:
DiffusionTerm(D1)
represents a typical 2nd-order diffusion term of the form
\[\nabla\cdot\left(D_1 \nabla \phi\right)\]and:
DiffusionTerm((D1,D2))
represents a 4th-order Cahn-Hilliard term of the form
\[\nabla \cdot \left\{ D_1 \nabla \left[ \nabla\cdot\left( D_2 \nabla \phi\right) \right] \right\}\]and so on.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.DiffusionTermCorrection(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTermCreate a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.DiffusionTermNoCorrection(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTermCreate a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.DistanceVariable(*args, **kwds)¶
Bases:
CellVariableA DistanceVariable object calculates \(\phi\) so it satisfies,
\[\abs{\nabla \phi} = 1\]using the fast marching method with an initial condition defined by the zero level set. The solution can either be first or second order.
Here we will define a few test cases. Firstly a 1D test case
>>> from fipy.meshes import Grid1D >>> from fipy.tools import serialComm >>> mesh = Grid1D(dx = .5, nx = 8, communicator=serialComm) >>> from .distanceVariable import DistanceVariable >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., 1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> answer = (-1.75, -1.25, -.75, -0.25, 0.25, 0.75, 1.25, 1.75) >>> print(var.allclose(answer)) 1
A 1D test case with very small dimensions.
>>> dx = 1e-10 >>> mesh = Grid1D(dx = dx, nx = 8, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., 1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> answer = numerix.arange(8) * dx - 3.5 * dx >>> print(var.allclose(answer)) 1
A 2D test case to test _calcTrialValue for a pathological case.
>>> dx = 1. >>> dy = 2. >>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = dx, dy = dy, nx = 2, ny = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., 1., -1., 1.))
>>> var.calcDistanceFunction() >>> vbl = -dx * dy / numerix.sqrt(dx**2 + dy**2) / 2. >>> vbr = dx / 2 >>> vml = dy / 2. >>> crossProd = dx * dy >>> dsq = dx**2 + dy**2 >>> top = vbr * dx**2 + vml * dy**2 >>> sqrt = crossProd**2 *(dsq - (vbr - vml)**2) >>> sqrt = numerix.sqrt(max(sqrt, 0)) >>> vmr = (top + sqrt) / dsq >>> answer = (vbl, vbr, vml, vmr, vbl, vbr) >>> print(var.allclose(answer)) 1
The extendVariable method solves the following equation for a given extensionVariable.
\[\nabla u \cdot \nabla \phi = 0\]using the fast marching method with an initial condition defined at the zero level set.
>>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> extensionVar = CellVariable(mesh = mesh, value = (-1, .5, 2, -1)) >>> tmp = 1 / numerix.sqrt(2) >>> print(var.allclose((-tmp / 2, 0.5, 0.5, 0.5 + tmp))) 1 >>> var.extendVariable(extensionVar, order=1) >>> print(extensionVar.allclose((1.25, .5, 2, 1.25))) 1 >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., ... 1., 1., 1., ... 1., 1., 1.)) >>> var.calcDistanceFunction(order=1) >>> extensionVar = CellVariable(mesh = mesh, value = (-1., .5, -1., ... 2., -1., -1., ... -1., -1., -1.))
>>> v1 = 0.5 + tmp >>> v2 = 1.5 >>> tmp1 = (v1 + v2) / 2 + numerix.sqrt(2. - (v1 - v2)**2) / 2 >>> tmp2 = tmp1 + 1 / numerix.sqrt(2) >>> print(var.allclose((-tmp / 2, 0.5, 1.5, 0.5, 0.5 + tmp, ... tmp1, 1.5, tmp1, tmp2))) 1 >>> answer = (1.25, .5, .5, 2, 1.25, 0.9544, 2, 1.5456, 1.25) >>> var.extendVariable(extensionVar, order=1) >>> print(extensionVar.allclose(answer, rtol = 1e-4)) 1
Test case for a bug that occurs when initializing the distance variable at the interface. Currently it is assumed that adjacent cells that are opposite sign neighbors have perpendicular normal vectors. In fact the two closest cells could have opposite normals.
>>> mesh = Grid1D(dx = 1., nx = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., -1.)) >>> var.calcDistanceFunction() >>> print(var.allclose((-0.5, 0.5, -0.5))) 1
Testing second order. This example failed with Scikit-fmm.
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 4, ny = 4, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., 1., 1., ... -1., -1., 1., 1., ... 1., 1., 1., 1., ... 1, 1, 1, 1)) >>> var.calcDistanceFunction(order=2) >>> answer = [-1.30473785, -0.5, 0.5, 1.49923009, ... -0.5, -0.35355339, 0.5, 1.45118446, ... 0.5, 0.5, 0.97140452, 1.76215286, ... 1.49923009, 1.45118446, 1.76215286, 2.33721352] >>> print(numerix.allclose(var, answer, rtol=1e-9)) True
** A test for a bug in both LSMLIB and Scikit-fmm **
The following test gives different result depending on whether LSMLIB or Scikit-fmm is used. There is a deeper problem that is related to this issue. When a value becomes “known” after previously being a “trial” value it updates its neighbors’ values. In a second order scheme the neighbors one step away also need to be updated (if the in between cell is “known” and the far cell is a “trial” cell), but are not in either package. By luck (due to trial values having the same value), the values calculated in Scikit-fmm for the following example are correct although an example that didn’t work for Scikit-fmm could also be constructed.
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 4, ny = 4, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., ... 1., 1., -1., -1., ... 1., 1., -1., -1., ... 1., 1., -1., -1.)) >>> var.calcDistanceFunction(order=2) >>> var.calcDistanceFunction(order=2) >>> answer = [-0.5, -0.58578644, -1.08578644, -1.85136395, ... 0.5, 0.29289322, -0.58578644, -1.54389939, ... 1.30473785, 0.5, -0.5, -1.5, ... 1.49547948, 0.5, -0.5, -1.5]
The 3rd and 7th element are different for LSMLIB. This is because the 15th element is not “known” when the “trial” value for the 7th element is calculated. Scikit-fmm calculates the values in a slightly different order so gets a seemingly better answer, but this is just chance.
>>> print(numerix.allclose(var, answer, rtol=1e-9)) True
Creates a distanceVariable object.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- calcDistanceFunction(order=2)¶
Calculates the distanceVariable as a distance function.
- Parameters:
order ({1, 2}) – The order of accuracy for the distance function calculation
- property cellInterfaceAreas¶
Returns the length of the interface that crosses the cell
A simple 1D test:
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(dx = 1., nx = 4) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-1.5, -0.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, value=(0, 0., 1., 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, ... answer)) True
A 2D test case:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (1.5, 0.5, 1.5, ... 0.5, -0.5, 0.5, ... 1.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, ... value=(0, 1, 0, 1, 0, 1, 0, 1, 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, answer)) True
Another 2D test case:
>>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2) >>> from fipy.variables.cellVariable import CellVariable >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-0.5, 0.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, ... value=(0, numerix.sqrt(2) / 4, numerix.sqrt(2) / 4, 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, ... answer)) True
Test to check that the circumference of a circle is, in fact, \(2\pi r\).
>>> mesh = Grid2D(dx = 0.05, dy = 0.05, nx = 20, ny = 20) >>> r = 0.25 >>> x, y = mesh.cellCenters >>> rad = numerix.sqrt((x - .5)**2 + (y - .5)**2) - r >>> distanceVariable = DistanceVariable(mesh = mesh, value = rad) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas.sum(), 1.57984690073)) 1
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- extendVariable(extensionVariable, order=2)¶
Calculates the extension of extensionVariable from the zero level set.
- Parameters:
extensionVariable (CellVariable) – The variable to extend from the zero level set.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getLSMshape()¶
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- fipy.DummySolver¶
alias of
LinearGMRESSolver
- class fipy.DummyViewer(vars, title=None, **kwlimits)¶
Bases:
AbstractViewerSubstitute viewer that doesn’t do anything
Create a AbstractViewer object.
- Parameters:
vars (CellVariable or list) – the CellVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.ExplicitDiffusionTerm(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTermThe discretization for the ExplicitDiffusionTerm is given by
\[\int_V \nabla \cdot (\Gamma\nabla\phi) dV \simeq \sum_f \Gamma_f \frac{\phi_A^\text{old}-\phi_P^\text{old}}{d_{AP}} A_f\]where \(\phi_A^\text{old}\) and \(\phi_P^\text{old}\) are the old values of the variable. The term is added to the RHS vector and makes no contribution to the solution matrix.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.ExplicitUpwindConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractUpwindConvectionTermThe discretization for this
Termis given by\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P^\text{old} +(1-\alpha_f)\phi_A^\text{old}\) and \(\alpha_f\) is calculated using the upwind scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- exception fipy.ExplicitVariableError(s='Terms with explicit Variables cannot mix with Terms with implicit Variables.')¶
Bases:
Exception- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ExponentialConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTermThe discretization for this
Termis given by\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P +(1-\alpha_f)\phi_A\) and \(\alpha_f\) is calculated using the exponential scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.ExponentialNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariableRepresents an exponential distribution of random numbers with the probability distribution
\[\mu^{-1} e^{-\frac{x}{\mu}}\]with a mean parameter \(\mu\).
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> mean = Variable() >>> from fipy.meshes import Grid2D >>> noise = ExponentialNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), mean = mean)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.1, nx = 100)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> expdist = CellVariable(mesh = histogram.mesh) >>> x = histogram.mesh.cellCenters[0]
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=5) ... histoplot = Viewer(vars=(histogram, expdist), ... datamin=0, datamax=1.5)
>>> from fipy.tools.numerix import arange, exp
>>> for mu in arange(0.5, 3, 0.5): ... mean.value = (mu) ... expdist.value = ((1/mean)*exp(-x/mean)) ... if __name__ == '__main__': ... import sys ... print("mean: %g" % mean, file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.FaceVariable(*args, **kwds)¶
Bases:
_MeshVariable- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tupleofint) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self, \(\vec{u}\),
\[\nabla\cdot\vec{u} \approx \frac{\sum_f (\vec{u}\cdot\hat{n})_f A_f}{V_P}\]- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.FirstOrderAdvectionTerm(coeff=None)¶
Bases:
_NonDiffusionTermThe FirstOrderAdvectionTerm object constructs the b vector contribution for the advection term given by
\[u \abs{\nabla \phi}\]from the advection equation given by:
\[\frac{\partial \phi}{\partial t} + u \abs{\nabla \phi} = 0\]The construction of the gradient magnitude term requires upwinding. The formula used here is given by:
\[u_P \abs{\nabla \phi}_P = \max \left( u_P , 0 \right) \left[ \sum_A \min \left( \frac{ \phi_A - \phi_P } { d_{AP}}, 0 \right)^2 \right]^{1/2} + \min \left( u_P , 0 \right) \left[ \sum_A \max \left( \frac{ \phi_A - \phi_P } { d_{AP}}, 0 \right)^2 \right]^{1/2}\]Here are some simple test cases for this problem:
>>> from fipy.meshes import Grid1D >>> from fipy.solvers import * >>> SparseMatrix = LinearLUSolver()._matrixClass >>> mesh = Grid1D(dx = 1., nx = 3) >>> from fipy.variables.cellVariable import CellVariable
Trivial test:
>>> var = CellVariable(value = numerix.zeros(3, 'd'), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(0.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.zeros(3, 'd'), atol = 1e-10)) True
Less trivial test:
>>> var = CellVariable(value = numerix.arange(3), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(1.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((0., -1., -1.)), atol = 1e-10)) True
Even less trivial
>>> var = CellVariable(value = numerix.arange(3), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(-1.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((1., 1., 0.)), atol = 1e-10)) True
Another trivial test case (more trivial than a trivial test case standing on a harpsichord singing “trivial test cases are here again”)
>>> vel = numerix.array((-1, 2, -3)) >>> var = CellVariable(value = numerix.array((4, 6, 1)), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(vel)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, -vel * numerix.array((2, numerix.sqrt(5**2 + 2**2), 5)), atol = 1e-10)) True
Somewhat less trivial test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2) >>> vel = numerix.array((3, -5, -6, -3)) >>> var = CellVariable(value = numerix.array((3, 1, 6, 7)), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(vel)._buildMatrix(var, SparseMatrix) >>> answer = -vel * numerix.array((2, numerix.sqrt(2**2 + 6**2), 1, 0)) >>> print(numerix.allclose(b, answer, atol = 1e-10)) True
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.FixedFlux(faces, value)¶
Bases:
BoundaryConditionThe FixedFlux boundary condition adds a contribution, equivalent to a fixed flux (Neumann condition), to the equation’s RHS vector. The contribution, given by value, is only added to entries corresponding to the specified faces, and is weighted by the face areas.
- Parameters:
faces (
FaceVariableofbool) – Mask of faces where this condition applies.value (float) – Value to impose.
- __repr__()¶
Return repr(self).
- class fipy.FixedValue(faces, value)¶
Bases:
BoundaryConditionThe FixedValue boundary condition adds a contribution, equivalent to a fixed value (Dirichlet condition), to the equation’s RHS vector and coefficient matrix. The contributions are given by \(-\mathtt{value}\times G_{\text{face}}\) for the RHS vector and \(G_{\text{face}}\) for the coefficient matrix. The parameter \(G_{\text{face}}\) represents the term’s geometric coefficient, which depends on the type of term and the mesh geometry.
Contributions are only added to entries corresponding to the specified faces.
- Parameters:
faces (
FaceVariableofbool) – Mask of faces where this condition applies.value (float) – Value to impose.
- __repr__()¶
Return repr(self).
- class fipy.GammaNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariableRepresents a gamma distribution of random numbers with the probability distribution
\[x^{\alpha - 1}\frac{\beta^\alpha e^{-\beta x}}{\Gamma(\alpha)}\]with a shape parameter \(\alpha\), a rate parameter \(\beta\), and \(\Gamma(z) = \int_0^\infty t^{z - 1}e^{-t}\,dt\).
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> alpha = Variable() >>> beta = Variable() >>> from fipy.meshes import Grid2D >>> noise = GammaNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), shape = alpha, rate = beta)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.1, nx = 300)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> x = CellVariable(mesh=histogram.mesh, value=histogram.mesh.cellCenters[0]) >>> from scipy.special import gamma as Gamma >>> from fipy.tools.numerix import exp >>> gammadist = (x**(alpha - 1) * (beta**alpha * exp(-beta * x)) / Gamma(alpha))
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=30) ... histoplot = Viewer(vars=(histogram, gammadist), ... datamin=0, datamax=1)
>>> from fipy.tools.numerix import arange
>>> for shape in arange(1, 8, 1): ... alpha.value = shape ... for rate in arange(0.5, 2.5, 0.5): ... beta.value = rate ... if __name__ == '__main__': ... import sys ... print("alpha: %g, beta: %g" % (alpha, beta), file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.GaussianNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariableRepresents a normal (Gaussian) distribution of random numbers with mean \(\mu\) and variance \(\langle \eta(\vec{r}) \eta(\vec{r}\,') \rangle = \sigma^2\), which has the probability distribution
\[\frac{1}{\sigma\sqrt{2\pi}} \exp -\frac{(x - \mu)^2}{2\sigma^2}\]For example, the variance of thermal noise that is uncorrelated in space and time is often expressed as
\[\left\langle \eta(\vec{r}, t) \eta(\vec{r}\,', t') \right\rangle = M k_B T \delta(\vec{r} - \vec{r}\,')\delta(t - t')\]which can be obtained with:
sigmaSqrd = Mobility * kBoltzmann * Temperature / (mesh.cellVolumes * timeStep) GaussianNoiseVariable(mesh = mesh, variance = sigmaSqrd)
Note
If the time step will change as the simulation progresses, either through use of an adaptive iterator or by making manual changes at different stages, remember to declare timeStep as a Variable and to change its value with its setValue() method.
>>> import sys >>> from fipy.tools.numerix import *
>>> mean = 0. >>> variance = 4.
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(3)
We generate noise on a non-uniform Cartesian mesh with cell dimensions of \(x^2\) and \(y^3\).
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = arange(0.1, 5., 0.1)**2, dy = arange(0.1, 3., 0.1)**3) >>> from fipy.variables.cellVariable import CellVariable >>> volumes = CellVariable(mesh=mesh, value=mesh.cellVolumes) >>> noise = GaussianNoiseVariable(mesh = mesh, mean = mean, ... variance = variance / volumes)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise * sqrt(volumes), ... dx = 0.1, nx = 600, offset = -30)
and compare to a Gaussian distribution
>>> gauss = CellVariable(mesh = histogram.mesh) >>> x = histogram.mesh.cellCenters[0] >>> gauss.value = ((1/(sqrt(variance * 2 * pi))) * exp(-(x - mean)**2 / (2 * variance)))
>>> if __name__ == '__main__': ... from fipy.viewers import Viewer ... viewer = Viewer(vars=noise, ... datamin=-5, datamax=5) ... histoplot = Viewer(vars=(histogram, gauss))
>>> from builtins import range >>> for i in range(10): ... noise.scramble() ... if __name__ == '__main__': ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
Note that the noise exhibits larger amplitude in the small cells than in the large ones
but that the root-volume-weighted histogram is Gaussian.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- fipy.GeneralSolver¶
alias of
LinearLUSolver
- class fipy.Gmsh2D(arg, coordDimensions=2, communicator=DummyComm(), overlap=1, background=None)¶
Bases:
Mesh2DConstruct a 2D Mesh using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
>>> radius = 5. >>> side = 4. >>> squaredCircle = Gmsh2D(''' ... // A mesh consisting of a square inside a circle inside a circle ... ... // define the basic dimensions of the mesh ... ... cellSize = 1; ... radius = %(radius)g; ... side = %(side)g; ... ... // define the compass points of the inner circle ... ... Point(1) = {0, 0, 0, cellSize}; ... Point(2) = {-radius, 0, 0, cellSize}; ... Point(3) = {0, radius, 0, cellSize}; ... Point(4) = {radius, 0, 0, cellSize}; ... Point(5) = {0, -radius, 0, cellSize}; ... ... // define the compass points of the outer circle ... ... Point(6) = {-2*radius, 0, 0, cellSize}; ... Point(7) = {0, 2*radius, 0, cellSize}; ... Point(8) = {2*radius, 0, 0, cellSize}; ... Point(9) = {0, -2*radius, 0, cellSize}; ... ... // define the corners of the square ... ... Point(10) = {side/2, side/2, 0, cellSize/2}; ... Point(11) = {-side/2, side/2, 0, cellSize/2}; ... Point(12) = {-side/2, -side/2, 0, cellSize/2}; ... Point(13) = {side/2, -side/2, 0, cellSize/2}; ... ... // define the inner circle ... ... Circle(1) = {2, 1, 3}; ... Circle(2) = {3, 1, 4}; ... Circle(3) = {4, 1, 5}; ... Circle(4) = {5, 1, 2}; ... ... // define the outer circle ... ... Circle(5) = {6, 1, 7}; ... Circle(6) = {7, 1, 8}; ... Circle(7) = {8, 1, 9}; ... Circle(8) = {9, 1, 6}; ... ... // define the square ... ... Line(9) = {10, 13}; ... Line(10) = {13, 12}; ... Line(11) = {12, 11}; ... Line(12) = {11, 10}; ... ... // define the three boundaries ... ... Line Loop(1) = {1, 2, 3, 4}; ... Line Loop(2) = {5, 6, 7, 8}; ... Line Loop(3) = {9, 10, 11, 12}; ... ... // define the three domains ... ... Plane Surface(1) = {2, 1}; ... Plane Surface(2) = {1, 3}; ... Plane Surface(3) = {3}; ... ... // label the three domains ... ... // attention: if you use any "Physical" labels, you *must* label ... // all elements that correspond to FiPy Cells (Physical Surface in 2D ... // and Physical Volume in 3D) or Gmsh will not include them and FiPy ... // will not be able to include them in the Mesh. ... ... // note: if you do not use any labels, all Cells will be included. ... ... Physical Surface("Outer") = {1}; ... Physical Surface("Middle") = {2}; ... Physical Surface("Inner") = {3}; ... ... // label the "north-west" part of the exterior boundary ... ... // note: you only need to label the Face elements ... // (Physical Line in 2D and Physical Surface in 3D) that correspond ... // to boundaries you are interested in. FiPy does not need them to ... // construct the Mesh. ... ... Physical Line("NW") = {5}; ... ''' % locals())
It can be easier to specify certain domains and boundaries within Gmsh than it is to define the same domains and boundaries with FiPy expressions.
Here we compare obtaining the same Cells and Faces using FiPy’s parametric descriptions and Gmsh’s labels.
>>> x, y = squaredCircle.cellCenters
>>> middle = ((x**2 + y**2 <= radius**2) ... & ~((x > -side/2) & (x < side/2) ... & (y > -side/2) & (y < side/2)))
>>> print((middle == squaredCircle.physicalCells["Middle"]).all()) True
>>> X, Y = squaredCircle.faceCenters
>>> NW = ((X**2 + Y**2 > (1.99*radius)**2) ... & (X**2 + Y**2 < (2.01*radius)**2) ... & (X <= 0) & (Y >= 0))
>>> print((NW == squaredCircle.physicalFaces["NW"]).all()) True
It is possible to direct Gmsh to give the mesh different densities in different locations
>>> geo = ''' ... // A mesh consisting of a square ... ... // define the corners of the square ... ... Point(1) = {1, 1, 0, 1}; ... Point(2) = {0, 1, 0, 1}; ... Point(3) = {0, 0, 0, 1}; ... Point(4) = {1, 0, 0, 1}; ... ... // define the square ... ... Line(1) = {1, 2}; ... Line(2) = {2, 3}; ... Line(3) = {3, 4}; ... Line(4) = {4, 1}; ... ... // define the boundary ... ... Line Loop(1) = {1, 2, 3, 4}; ... ... // define the domain ... ... Plane Surface(1) = {1}; ... '''
>>> from fipy import CellVariable, numerix
>>> error = [] >>> bkg = None >>> from builtins import range >>> for refine in range(4): ... square = Gmsh2D(geo, background=bkg) ... x, y = square.cellCenters ... bkg = CellVariable(mesh=square, value=abs(x / 4) + 0.01) ... error.append(((2 * numerix.sqrt(square.cellVolumes) / bkg - 1)**2).cellVolumeAverage)
Check that the mesh is (semi)monotonically approaching the desired density (the first step may increase, depending on the number of partitions)
>>> print(numerix.greater(error[:-1], error[1:]).all()) True
and that the final density is close enough to the desired density
>>> print(error[-1] < 0.02) True
The initial mesh doesn’t have to be from Gmsh
>>> from fipy import Tri2D
>>> trisquare = Tri2D(nx=1, ny=1) >>> x, y = trisquare.cellCenters >>> bkg = CellVariable(mesh=trisquare, value=abs(x / 4) + 0.01) >>> std1 = (numerix.sqrt(2 * trisquare.cellVolumes) / bkg).std()
>>> square = Gmsh2D(geo, background=bkg) >>> x, y = square.cellCenters >>> bkg = CellVariable(mesh=square, value=abs(x / 4) + 0.01) >>> std2 = (numerix.sqrt(2 * square.cellVolumes) / bkg).std()
>>> print(std1 > std2) True
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.Gmsh2DIn3DSpace(arg, communicator=DummyComm(), overlap=1, background=None)¶
Bases:
Gmsh2DCreate a topologically 2D Mesh in 3D coordinates using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.Gmsh3D(arg, communicator=DummyComm(), overlap=1, background=None)¶
Bases:
MeshCreate a 3D Mesh using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.GmshGrid2D(dx=1.0, dy=1.0, nx=1, ny=None, coordDimensions=2, communicator=DummyComm(), overlap=1)¶
Bases:
Gmsh2DShould serve as a drop-in replacement for Grid2D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.GmshGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=1, ny=None, nz=None, communicator=DummyComm(), overlap=1)¶
Bases:
Gmsh3DShould serve as a drop-in replacement for Grid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- fipy.Grid1D(dx=1.0, nx=None, Lx=None, overlap=2, communicator=DummyComm())¶
Create a 1D Cartesian mesh
Factory function to select between
UniformGrid1DandNonUniformGrid1D. If Lx is specified the length of the domain is always Lx regardless of dx, unless dx is a list of spacings, in which case Lx will be the sum of dx and nx will be the count of dx.- Parameters:
dx (float) – Grid spacing in the horizontal direction
nx (int) – Number of cells in the horizontal direction
Lx (float) – Domain length in the horizontal direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- fipy.Grid2D(dx=1.0, dy=1.0, nx=None, ny=None, Lx=None, Ly=None, overlap=2, communicator=DummyComm())¶
Create a 2D Cartesian mesh
Factory function to select between
UniformGrid2DandNonUniformGrid2D. If L{x,y} is specified, the length of the domain is always L{x,y} regardless of d{x,y}, unless d{x,y} is a list of spacings, in which case L{x,y} will be the sum of d{x,y} and n{x,y} will be the count of d{x,y}.>>> print(Grid2D(Lx=3., nx=2).dx) 1.5
- Parameters:
dx (float) – Grid spacing in the horizontal direction
dy (float) – Grid spacing in the vertical direction
nx (int) – Number of cells in the horizontal direction
ny (int) – Number of cells in the vertical direction
Lx (float) – Domain length in the horizontal direction
Ly (float) – Domain length in the vertical direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- fipy.Grid3D(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, Lx=None, Ly=None, Lz=None, overlap=2, communicator=DummyComm())¶
Create a 3D Cartesian mesh
Factory function to select between
UniformGrid3DandNonUniformGrid3D. If L{x,y,z} is specified, the length of the domain is always L{x,y,z} regardless of d{x,y,z}, unless d{x,y,z} is a list of spacings, in which case L{x,y,z} will be the sum of d{x,y,z} and n{x,y,z} will be the count of d{x,y,z}.- Parameters:
dx (float) – Grid spacing in the horizontal direction
dy (float) – Grid spacing in the vertical direction
dz (float) – Grid spacing in the depth direction
nx (int) – Number of cells in the horizontal direction
ny (int) – Number of cells in the vertical direction
nz (int) – Number of cells in the depth direction
Lx (float) – Domain length in the horizontal direction
Ly (float) – Domain length in the vertical direction
Lz (float) – Domain length in the depth direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- class fipy.HistogramVariable(*args, **kwds)¶
Bases:
CellVariableProduces a histogram of the values of the supplied distribution.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.HybridConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTermThe discretization for this
Termis given by\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P +(1-\alpha_f)\phi_A\) and \(\alpha_f\) is calculated using the hybrid scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- exception fipy.IllConditionedPreconditionerWarning(solver, iter, relres)¶
Bases:
PreconditionerWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.ImplicitDiffusionTerm¶
alias of
DiffusionTerm
- class fipy.ImplicitSourceTerm(coeff=0.0, var=None)¶
Bases:
SourceTermThe ImplicitSourceTerm represents
\[\int_V \phi S \,dV \simeq \phi_P S_P V_P\]where \(S\) is the coeff value.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- exception fipy.IncorrectSolutionVariable(s='The solution variable is incorrect.')¶
Bases:
Exception- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.L1error(var, matrix, RHSvector)¶
- \[\frac{\|\mathtt{var} - \mathtt{var}^\text{old}\|_1} {\|\mathtt{var}^\text{old}\|_1}\]
where \(\|\vec{x}\|_1\) is the \(L^1\) norm of \(\vec{x}\).
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- fipy.L2error(var, matrix, RHSvector)¶
- \[\frac{\|\mathtt{var} - \mathtt{var}^\text{old}\|_2} {\|\mathtt{var}^\text{old}\|_2}\]
where \(\|\vec{x}\|_2\) is the \(L^2\) norm of \(\vec{x}\).
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- fipy.LINFerror(var, matrix, RHSvector)¶
- \[\frac{\|\mathtt{var} - \mathtt{var}^\text{old}\|_\infty} {\|\mathtt{var}^\text{old}\|_\infty}\]
where \(\|\vec{x}\|_\infty\) is the \(L^\infty\) norm of \(\vec{x}\).
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- class fipy.LinearBicgstabSolver(tolerance=1e-15, iterations=2000, precon=None)¶
Bases:
_ScipyKrylovSolverThe LinearBicgstabSolver is an interface to the Bicgstab solver in Scipy, with no preconditioning by default.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.LinearCGSSolver(tolerance=1e-15, iterations=2000, precon=None)¶
Bases:
_ScipyKrylovSolverThe LinearCGSSolver is an interface to the CGS solver in Scipy, with no preconditioning by default.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.LinearGMRESSolver(tolerance=1e-15, iterations=2000, precon=None)¶
Bases:
_ScipyKrylovSolverThe LinearGMRESSolver is an interface to the GMRES solver in Scipy, with no preconditioning by default.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.LinearLUSolver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
_ScipySolverThe LinearLUSolver solves a linear system of equations using LU-factorization. The LinearLUSolver is a wrapper class for the the Scipy scipy.sparse.linalg.splu module.
Create a Solver object.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.LinearPCGSolver(tolerance=1e-15, iterations=2000, precon=None)¶
Bases:
_ScipyKrylovSolverThe LinearPCGSolver is an interface to the CG solver in Scipy, with no preconditioning by default.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.Matplotlib1DViewer(vars, title=None, xlog=False, ylog=False, limits={}, legend='upper left', axes=None, **kwlimits)¶
Bases:
AbstractMatplotlibViewerDisplays a y vs. x plot of one or more 1D CellVariable objects using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid1D(nx=100) >>> x, = mesh.cellCenters >>> xVar = fp.CellVariable(mesh=mesh, name="x", value=x) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib1DViewer(vars=(fp.numerix.sin(k * xVar) + 2, ... fp.numerix.cos(k * xVar / fp.numerix.pi) + 2), ... xmin=10, xmax=90, ... datamin=1.1, datamax=4.0, ... title="Matplotlib1DViewer test") >>> for kval in fp.numerix.arange(0, 0.3, 0.03): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib1DViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
- Parameters:
vars (CellVariable or list) – CellVariable objects to plot
title (str, optional) – displayed at the top of the Viewer window
xlog (bool) – log scaling of x axis if True
ylog (bool) – log scaling of y axis if True
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
legend (str) – place a legend at the specified position, if not None
axes (Axes) – if not None, vars will be plotted into this Matplotlib
Axesobject
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property limits¶
- property lines¶
The collection of Matplotlib
Line2Dobjects representing the plotted data.
- property log¶
Whether data has logarithmic scaling
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.Matplotlib2DContourViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, number=None, levels=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays a contour plot of a 2D CellVariable object.
The Matplotlib2DContourViewer plots a 2D CellVariable using Matplotlib.
Creates a Matplotlib2DContourViewer.
- Parameters:
vars (CellVariable) – Variable to display
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
number (int, optional) – Determines the number and positions of the contour lines / regions. (deprecated, use levels=).
levels (int or array-like, optional) – Determines the number and positions of the contour lines / regions. If an int n, tries to automatically choose no more than n+1 “nice” contour levels over the range of vars. If array-like, draw contour lines at the specified levels. The values must be in increasing order. E.g. to draw just the zero contour pass
levels=[0].figaspect (float) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property levels¶
The number of automatically-chosen contours or their values.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.Matplotlib2DGridContourViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, levels=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays a contour plot of a 2D CellVariable object.
The Matplotlib2DGridContourViewer plots a 2D CellVariable using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DGridContourViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DGridContourViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.levels = 2
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DGridContourViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the
Colormap. Defaults to matplotlib.cm.jetcolorbar (bool, optional) – plot a color bar if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
levels (int or array-like, optional) – Determines the number and positions of the contour lines / regions. If an int n, tries to automatically choose no more than n+1 “nice” contour levels over the range of vars. If array-like, draw contour lines at the specified levels. The values must be in increasing order. E.g. to draw just the zero contour pass
levels=[0].figaspect (float, optional) – desired aspect ratio of figure. If a number, use that aspect ratio. If auto, the aspect ratio will be determined from the vars’s mesh.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property levels¶
The number of automatically-chosen contours or their values.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.Matplotlib2DGridViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays an image plot of a 2D CellVariable object using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DGridViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DGridViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DGridViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DGridViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
cmap (Colormap, optional) – the
Colormap. Defaults to matplotlib.cm.jetxmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.Matplotlib2DViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays a contour plot of a 2D CellVariable object.
The Matplotlib2DViewer plots a 2D CellVariable using Matplotlib.
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
cmap (Colormap, optional) – the
Colormap. Defaults to matplotlib.cm.jetxmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib
Axesobjectfigaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property collection¶
The Matplotlib
PolyCollectionrepresenting the cells.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.MatplotlibStreamViewer(vars, title=None, log=False, limits={}, axes=None, figaspect='auto', density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays a stream plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib
One issue is that this Viewer relies on scipy.interpolate.griddata, which interpolates on the convex hull of the data. The results is that streams are plotted across any concavities in the mesh.
Another issue is that it does not seem possible to remove the streams without calling cla(), which means that different set of streams cannot be overlaid.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibStreamViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibStreamViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibStreamViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibStreamViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibStreamViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibStreamViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a MatplotlibStreamViewer.
- Parameters:
vars (CellVariable or FaceVariable) – rank-1 Variable to display
title (str, optional) – displayed at the top of the Viewer window
log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
density (float or (float, float), optional) – Controls the closeness of streamlines. When
density = 1, the domain is divided into a 30x30 grid. density linearly scales this grid. Each cell in the grid can have, at most, one traversing streamline. For different densities in each direction, use a tuple (density_x, density_y).linewidth (array_like or CellVariable or FaceVariable, optional) – The width of the stream lines. With a rank-0 CellVariable or FaceVariable the line width can be varied across the grid. The MeshVariable must have the same type and be defined on the same Mesh as vars.
color (str or CellVariable or FaceVariable, optional) – The streamline color as a matplotlib color code or a field of numbers. If given a rank-0 CellVariable or FaceVariable, its values are converted to colors using cmap and norm. The MeshVariable must have the same type and be defined on the same Mesh as vars.
cmap (Colormap, optional) – Colormap used to plot streamlines and arrows. This is only used if color is a MeshVariable.
norm (Normalize, optional) – Normalize object used to scale luminance data to 0, 1. If
None, stretch (min, max) to (0, 1). Only necessary when color is a MeshVariable.arrowsize (float, optional) – Scaling factor for the arrow size.
arrowstyle (str, optional) – Arrow style specification. See ~matplotlib.patches.FancyArrowPatch.
minlength (float, optional) – Minimum length of streamline in axes coordinates.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property kwargs¶
keyword arguments to pass to
streamplot().
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.MatplotlibVectorViewer(vars, title=None, scale=None, sparsity=None, log=False, limits={}, axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewerDisplays a vector plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibVectorViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibVectorViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> for sparsity in numerix.arange(5000, 0, -500): ... viewer.quiver(sparsity=sparsity) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibVectorViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibVectorViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibVectorViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> for sparsity in numerix.arange(5000, 0, -500): ... viewer.quiver(sparsity=sparsity) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibVectorViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable or FaceVariable) – rank-1 Variable to display
title (str, optional) – displayed at the top of the Viewer window
scale (float, optional) – if not None, scale all arrow lengths by this value
sparsity (int, optional) – if not None, then this number of arrows will be randomly chosen (weighted by the cell volume or face area)
log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes.
- property cmap¶
The Matplotlib
Colormap.
- property colorbar¶
The Matplotlib
Colorbar.
- property fig¶
The Matplotlib
Figure.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figurenumber.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- quiver(sparsity=None, scale=None)¶
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- fipy.MatplotlibViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, **kwlimits)¶
Generic function for creating a MatplotlibViewer.
The MatplotlibViewer factory will search the module tree and return an instance of the first MatplotlibViewer it finds of the correct dimension and rank.
It is possible to view different
Variables against different Matplotlib Axes>>> from matplotlib import pyplot as plt >>> from fipy import *
>>> plt.ion() >>> fig = plt.figure()
>>> ax1 = plt.subplot((221)) >>> ax2 = plt.subplot((223)) >>> ax3 = plt.subplot((224))
>>> k = Variable(name="k", value=0.)
>>> mesh1 = Grid1D(nx=100) >>> x, = mesh1.cellCenters >>> xVar = CellVariable(mesh=mesh1, name="x", value=x) >>> viewer1 = MatplotlibViewer(vars=(numerix.sin(0.1 * k * xVar), numerix.cos(0.1 * k * xVar / numerix.pi)), ... limits={'xmin': 10, 'xmax': 90}, ... datamin=-0.9, datamax=2.0, ... title="Grid1D test", ... axes=ax1, ... legend=None)
>>> mesh2 = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh2.cellCenters >>> xyVar = CellVariable(mesh=mesh2, name="x y", value=x * y) >>> viewer2 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Grid2D test", ... axes=ax2, ... colorbar=None)
>>> mesh3 = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh3.cellCenters >>> xyVar = CellVariable(mesh=mesh3, name="x y", value=x * y) >>> viewer3 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Irregular 2D test", ... axes=ax3, ... cmap = plt.cm.OrRd)
>>> viewer = MultiViewer(viewers=(viewer1, viewer2, viewer3)) >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot()
>>> viewer._promptForOpinion()
- Parameters:
vars (CellVariable or list) – the Variable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the
Colormap. Defaults to matplotlib.cm.jetcolorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
- exception fipy.MatrixIllConditionedWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.MaximumIterationWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.MayaviClient(vars, title=None, daemon_file=None, fps=1.0, **kwlimits)¶
Bases:
AbstractViewerThe MayaviClient uses the Mayavi python plotting package.
>>> import fipy as fp >>> mesh = fp.Grid1D(nx=100) >>> x, = mesh.cellCenters >>> xVar = fp.CellVariable(mesh=mesh, name="x", value=x) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=(fp.numerix.sin(k * xVar) + 2, ... fp.numerix.cos(k * xVar / fp.numerix.pi) + 2), ... xmin=10, xmax=90, ... datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> for kval in fp.numerix.arange(0, 0.3, 0.03): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = fp.Grid3D(nx=50, ny=100, nz=10, dx=0.1, dy=0.01, dz=0.1) >>> x, y, z = mesh.cellCenters >>> xyzVar = fp.CellVariable(mesh=mesh, name=r"x y z", value=x * y * z) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyzVar) + 2, ... ymin=0.1, ymax=0.9, ... datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
Create a MayaviClient.
- Parameters:
vars (CellVariable or list) – CellVariable objects to plot
title (str, optional) – displayed at the top of the Viewer window
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
daemon_file (str, optional) – the path to the script to run the separate Mayavi viewer process. Defaults to fipy/viewers/mayaviViewer/mayaviDaemon.py
fps (float, optional) – frames per second to attempt to display
- __del__()¶
- property fps¶
The frames per second to attempt to display.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- exception fipy.MeshDimensionError¶
Bases:
IndexError- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ModularVariable(*args, **kwds)¶
Bases:
CellVariableThe ModularVariable defines a variable that exists on the circle between \(-\pi\) and \(\pi\)
The following examples show how ModularVariable works. When subtracting the answer wraps back around the circle.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.tools import numerix >>> pi = numerix.pi >>> v1 = ModularVariable(mesh = mesh, value = (2*pi/3, -2*pi/3)) >>> v2 = ModularVariable(mesh = mesh, value = -2*pi/3) >>> print(numerix.allclose(v2 - v1, (2*pi/3, 0))) 1
Obtaining the arithmetic face value.
>>> print(numerix.allclose(v1.arithmeticFaceValue, (2*pi/3, pi, -2*pi/3))) 1
Obtaining the gradient.
>>> print(numerix.allclose(v1.grad, ((pi/3, pi/3),))) 1
Obtaining the gradient at the faces.
>>> print(numerix.allclose(v1.faceGrad, ((0, 2*pi/3, 0),))) 1
Obtaining the gradient at the faces but without modular arithmetic.
>>> print(numerix.allclose(v1.faceGradNoMod, ((0, -4*pi/3, 0),))) 1
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tupleofint) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]Adjusted for a ModularVariable
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable (second-order gradient). Adjusted for a ModularVariable
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceGradNoMod¶
Return \(\nabla \phi\) as a rank-1 FaceVariable (second-order gradient). Not adjusted for a ModularVariable
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient). Adjusted for a ModularVariable
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values. Test case due to bug.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 1) >>> var = ModularVariable(mesh=mesh, value=1., hasOld=1) >>> var.updateOld() >>> var[:] = 2 >>> answer = CellVariable(mesh=mesh, value=1.) >>> print(var.old.allclose(answer)) True
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.MultiViewer(viewers)¶
Bases:
AbstractViewerTreat a collection of different viewers (such for different 2D plots or 1D plots with different axes) as a single viewer that will plot() all subviewers simultaneously.
- Parameters:
viewers (
listof ~fipy.viewers.viewer.Viewer) – the viewers to bind together
- property limits¶
- plot()¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.NthOrderBoundaryCondition(faces, value, order)¶
Bases:
BoundaryConditionThis boundary condition is generally used in conjunction with a ImplicitDiffusionTerm that has multiple coefficients. It does not have any direct effect on the solution matrices, but its derivatives do.
Creates an NthOrderBoundaryCondition.
- Parameters:
faces (
FaceVariableofbool) – Mask of faces where this condition applies.value (float) – Value to impose.
order (int) – Order of the boundary condition. An order of 0 corresponds to a FixedValue and an order of 1 corresponds to a FixedFlux. Even and odd orders behave like FixedValue and FixedFlux objects, respectively, but apply to higher order terms.
- __repr__()¶
Return repr(self).
- class fipy.PeriodicGrid1D(dx=1.0, nx=None, overlap=2, *args, **kwargs)¶
Bases:
NonUniformGrid1DCreates a Periodic grid mesh.
>>> mesh = PeriodicGrid1D(dx = (1, 2, 3))
>>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [3])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-999), ... [[2, 0, 1, 2], ... [0, 1, 2, -999]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [ 2., 1.5, 2.5, 1.5])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[ 2., 1.5, 2.5], ... [ 1.5, 2.5, 2. ]])) True
>>> print(numerix.allclose(mesh.faceNormals, ... [[ 1., 1., 1., 1.]])) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[1, 2, 2], ... [0, 1, 0]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
Defined outside of a geometry class since we need the CellVariable version of cellCenters; that is, the cellCenters defined in
fipy.meshes.meshand not in any geometry (since a CellVariable requires a reference to a mesh).
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2D(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2DCreates a periodic 2D grid mesh with horizontal faces numbered first and then vertical faces. Vertices and cells are numbered in the usual way.
>>> from fipy import numerix
>>> mesh = PeriodicGrid2D(dx = 1., dy = 0.5, nx = 2, ny = 2)
>>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [ 4, 5, 8, 11])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-1), ... [[2, 3, 0, 1, 2, 3, 1, 0, 1, 3, 2, 3], ... [0, 1, 2, 3, -1, -1, 0, 1, -1, 2, 3, -1]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [ 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 1., 1., 0.5, 1., 1., 0.5])) True
>>> print(numerix.allclose(mesh.cellFaceIDs, ... [[0, 1, 2, 3], ... [7, 6, 10, 9], ... [2, 3, 0, 1], ... [6, 7, 9, 10]])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[ 0.5, 0.5, 0.5, 0.5], ... [ 1., 1., 1., 1. ], ... [ 0.5, 0.5, 0.5, 0.5], ... [ 1., 1., 1., 1. ]])) True
>>> normals = [[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], ... [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]]
>>> print(numerix.allclose(mesh.faceNormals, normals)) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[4, 5, 7, 8], ... [3, 4, 6, 7], ... [1, 2, 4, 5], ... [0, 1, 3, 4]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2DLeftRight(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2DTopBottom(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3DCreates a periodic 3D grid mesh with horizontal faces numbered first and then vertical faces. Vertices and cells are numbered in the usual way.
>>> from fipy import numerix
>>> mesh = PeriodicGrid3D(dx=1., dy=0.5, dz=2., nx=2, ny=2, nz=1) >>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [4, 5, 6, 7, 12, 13, 16, 19])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-1), ... [[0, 1, 2, 3, 0, 1, 2, 3, 2, 3, ... 0, 1, 2, 3, 1, 0, 1, 3, 2, 3], ... [0, 1, 2, 3, -1, -1, -1, -1, 0, 1, ... 2, 3, -1, -1, 0, 1, -1, 2, 3, -1]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [2., 2., 2., 2., 1., 1., 1., 1., 0.5, 0.5, ... 0.5, 0.5, 0.25, 0.25, 1., 1., 0.5, 1., 1., 0.5])) True
>>> print(numerix.allclose(mesh.cellFaceIDs, ... [[14, 15, 17, 18], ... [15, 14, 18, 17], ... [8, 9, 10, 11], ... [10, 11, 8, 9], ... [0, 1, 2, 3], ... [0, 1, 2, 3]])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[1., 1., 1., 1.], ... [1., 1., 1., 1.], ... [0.5, 0.5, 0.5, 0.5], ... [0.5, 0.5, 0.5, 0.5], ... [2., 2., 2., 2.], ... [2., 2., 2., 2.]])) True
>>> normals = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], ... [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], ... [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
>>> print(numerix.allclose(mesh.faceNormals, normals)) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[13, 14, 16, 17], ... [12, 13, 15, 16], ... [10, 11, 13, 14], ... [9, 10, 12, 13], ... [4, 5, 7, 8], ... [3, 4, 6, 7], ... [1, 2, 4, 5], ... [0, 1, 3, 4]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRight(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRightFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRightTopBottom(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DTopBottom(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DTopBottomFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=DummyComm(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PhysicalField(value, unit=None, array=None)¶
Bases:
objectPhysical field or quantity with units
Physical Fields can be constructed in one of two ways:
PhysicalField(*value*, *unit*), where *value* is a number of arbitrary type and *unit* is a string containing the unit name
>>> print(PhysicalField(value = 10., unit = 'm')) 10.0 m
PhysicalField(*string*), where *string* contains both the value and the unit. This form is provided to make interactive use more convenient
>>> print(PhysicalField(value = "10. m")) 10.0 m
Dimensionless quantities, with a unit of 1, can be specified in several ways
>>> print(PhysicalField(value = "1")) 1.0 1 >>> print(PhysicalField(value = 2., unit = " ")) 2.0 1 >>> print(PhysicalField(value = 2.)) 2.0 1
Physical arrays are also possible (and are the reason this code was adapted from Konrad Hinsen’s original PhysicalQuantity). The value can be a Numeric array:
>>> a = numerix.array(((3., 4.), (5., 6.))) >>> print(PhysicalField(value = a, unit = "m")) [[ 3. 4.] [ 5. 6.]] m
or a tuple:
>>> print(PhysicalField(value = ((3., 4.), (5., 6.)), unit = "m")) [[ 3. 4.] [ 5. 6.]] m
or as a single value to be applied to every element of a supplied array:
>>> print(PhysicalField(value = 2., unit = "m", array = a)) [[ 2. 2.] [ 2. 2.]] m
Every element in an array has the same unit, which is stored only once for the whole array.
- __abs__()¶
Return the absolute value of the quantity. The unit is unchanged.
>>> print(abs(PhysicalField(((3., -2.), (-1., 4.)), 'm'))) [[ 3. 2.] [ 1. 4.]] m
- __add__(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __array__(t=None)¶
Return a dimensionless PhysicalField as a Numeric
array.>>> print(numerix.array(PhysicalField(((2., 3.), (4., 5.)), "m/m"))) [[ 2. 3.] [ 4. 5.]]
As a special case, fields with angular units are converted to base units (radians) and then assumed dimensionless.
>>> print(numerix.array(PhysicalField(((2., 3.), (4., 5.)), "deg"))) [[ 0.03490659 0.05235988] [ 0.06981317 0.08726646]]
If the array is not dimensionless, the numerical value in its base units is returned.
>>> numerix.array(PhysicalField(((2., 3.), (4., 5.)), "mm")) array([[ 0.002, 0.003], [ 0.004, 0.005]])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> from fipy.tools.dimensions.physicalField import PhysicalField >>> print(type(numerix.array([1.0, 2.0]) * PhysicalField([1.0, 2.0], unit="m"))) <class 'fipy.tools.dimensions.physicalField.PhysicalField'>
>>> print(type(numerix.array([1.0, 2.0]) * PhysicalField([1.0, 2.0]))) <class 'fipy.tools.dimensions.physicalField.PhysicalField'>
>>> from scipy.special import gamma as Gamma >>> print(isinstance(Gamma(PhysicalField([1.0, 2.0])), type(numerix.array(1)))) 1
- __bool__()¶
Test if the quantity is zero.
Should this only pass if the unit offset is zero?
- __div__(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- __eq__(other)¶
Return self==value.
- __float__()¶
Return a dimensionless PhysicalField quantity as a float.
>>> float(PhysicalField("2. m/m")) 2.0
As a special case, quantities with angular units are converted to base units (radians) and then assumed dimensionless.
>>> print(numerix.round_(float(PhysicalField("2. deg")), 6)) 0.034907
If the quantity is not dimensionless, the conversion fails.
>>> float(PhysicalField("2. m")) Traceback (most recent call last): ... TypeError: Not possible to convert a PhysicalField with dimensions to float
Just as a Numeric array cannot be cast to float, neither can PhysicalField arrays
>>> float(PhysicalField(((2., 3.), (4., 5.)), "m/m")) Traceback (most recent call last): ... TypeError: only ...-1 arrays can be converted to Python scalars
- __ge__(other)¶
Return self>=value.
- __getitem__(index)¶
Return the specified element of the array. The unit of the result will be the unit of the array.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> print(a[1, 1]) 6.0 m
- __gt__(other)¶
Compare self to other, returning an array of Boolean values corresponding to the test against each element.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> print(numerix.allclose(a > PhysicalField("13 ft"), ... [[False, True], [ True, True]])) True
Appropriately formatted dimensional quantity strings can also be compared.
>>> print(numerix.allclose(a > "13 ft", ... [[False, True], [ True, True]])) True
Arrays are compared element to element
>>> print(numerix.allclose(a > PhysicalField(((3., 13.), (17., 6.)), "ft"), ... [[ True, True], [False, True]])) True
Units must be compatible
>>> print(a > PhysicalField("1 lb")) Traceback (most recent call last): ... TypeError: Incompatible units
And so must array dimensions
>>> print(a > PhysicalField(((3., 13., 4.), (17., 6., 2.)), "ft")) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __hash__()¶
Return hash(self).
- __le__(other)¶
Return self<=value.
- __len__()¶
- __lt__(other)¶
Return self<value.
- __mod__(other)¶
Return the remainder of dividing two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(11., 'm') % PhysicalField(2., 's')) 1.0 m/s
- __mul__(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- __ne__(other)¶
Return self!=value.
- __neg__()¶
Return the negative of the quantity. The unit is unchanged.
>>> print(-PhysicalField(((3., -2.), (-1., 4.)), 'm')) [[-3. 2.] [ 1. -4.]] m
- __nonzero__()¶
Test if the quantity is zero.
Should this only pass if the unit offset is zero?
- __pos__()¶
- __pow__(other)¶
Raise a PhysicalField to a power. The unit is raised to the same power.
>>> print(PhysicalField(10., 'm')**2) 100.0 m**2
- __radd__(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __rdiv__(other)¶
- __repr__()¶
Return representation of a physical quantity suitable for re-use
>>> PhysicalField(value = 3., unit = "eV") PhysicalField(3.0,'eV')
- __rmul__(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
Assign the specified element of the array, performing appropriate conversions.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> a[0, 1] = PhysicalField("6 ft") >>> print(a) [[ 3. 1.8288] [ 5. 6. ]] m >>> a[1, 0] = PhysicalField("2 min") Traceback (most recent call last): ... TypeError: Incompatible units
- __str__()¶
Return human-readable form of a physical quantity
>>> print(PhysicalField(value = 3., unit = "eV")) 3.0 eV
- __sub__(other)¶
Subtract two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') - PhysicalField(10., 'm')) 9.99 km >>> print(PhysicalField(10., 'km') - PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __truediv__(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- add(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- allclose(other, atol=None, rtol=1e-08)¶
This function tests whether or not self and other are equal subject to the given relative and absolute tolerances. The formula used is:
| self - other | < atol + rtol * | other |
This means essentially that both elements are small compared to atol or their difference divided by other’s value is small compared to rtol.
- allequal(other)¶
This function tests whether or not self and other are exactly equal.
- arccos()¶
Return the inverse cosine of the PhysicalField in radians
>>> print(PhysicalField(0).arccos().allclose("1.57079632679 rad")) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1 m").arccos(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arccosh()¶
Return the inverse hyperbolic cosine of the PhysicalField
>>> print(numerix.allclose(PhysicalField(2).arccosh(), ... 1.31695789692)) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1. m").arccosh(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arcsin()¶
Return the inverse sine of the PhysicalField in radians
>>> print(PhysicalField(1).arcsin().allclose("1.57079632679 rad")) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1 m").arcsin(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctan()¶
Return the arctangent of the PhysicalField in radians
>>> print(numerix.round_(PhysicalField(1).arctan(), 6)) 0.785398
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1 m").arctan(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctan2(other)¶
Return the arctangent of self divided by other in radians
>>> print(numerix.round_(PhysicalField(2.).arctan2(PhysicalField(5.)), 6)) 0.380506
The input PhysicalField objects must be in the same dimensions
>>> print(numerix.round_(PhysicalField(2.54, "cm").arctan2(PhysicalField(1., "inch")), 6)) 0.785398
>>> print(numerix.round_(PhysicalField(2.).arctan2(PhysicalField("5. m")), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctanh()¶
Return the inverse hyperbolic tangent of the PhysicalField
>>> print(PhysicalField(0.5).arctanh()) 0.549306144334
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1 m").arctanh(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- ceil()¶
Return the smallest integer greater than or equal to the PhysicalField.
>>> print(PhysicalField(2.2, "m").ceil()) 3.0 m
- conjugate()¶
Return the complex conjugate of the PhysicalField.
>>> print(PhysicalField(2.2 - 3j, "ohm").conjugate() == PhysicalField(2.2 + 3j, "ohm")) True
- convertToUnit(unit)¶
Changes the unit to unit and adjusts the value such that the combination is equivalent. The new unit is by a string containing its name. The new unit must be compatible with the previous unit of the object.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> e.convertToUnit('kcal/mol') >>> print(e) 1694.27557621 kcal/mol
- copy()¶
Make a duplicate.
>>> a = PhysicalField(1, unit = 'inch') >>> b = a.copy()
The duplicate will not reflect changes made to the original
>>> a.convertToUnit('cm') >>> print(a) 2.54 cm >>> print(b) 1 inch
Likewise for arrays
>>> a = PhysicalField(numerix.array((0, 1, 2)), unit = 'm') >>> b = a.copy() >>> a[0] = 3 >>> print(a) [3 1 2] m >>> print(b) [0 1 2] m
- cos()¶
Return the cosine of the PhysicalField
>>> print(numerix.round_(PhysicalField(2*numerix.pi/6, "rad").cos(), 6)) 0.5 >>> print(numerix.round_(PhysicalField(60., "deg").cos(), 6)) 0.5
The units of the PhysicalField must be an angle
>>> PhysicalField(60., "m").cos() Traceback (most recent call last): ... TypeError: Incompatible units
- cosh()¶
Return the hyperbolic cosine of the PhysicalField
>>> PhysicalField(0.).cosh() 1.0
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").cosh() Traceback (most recent call last): ... TypeError: Incompatible units
- divide(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- dot(other)¶
Return the dot product of self with other. The resulting unit is the product of the units of self and other.
>>> v = PhysicalField(((5., 6.), (7., 8.)), "m") >>> print(PhysicalField(((1., 2.), (3., 4.)), "m").dot(v)) [ 26. 44.] m**2
- floor()¶
Return the largest integer less than or equal to the PhysicalField.
>>> print(PhysicalField(2.2, "m").floor()) 2.0 m
- getsctype(default=None)¶
Returns the NumPy sctype of the underlying array.
>>> PhysicalField(1, 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> PhysicalField(1., 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> PhysicalField((1, 1.), 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- inBaseUnits()¶
Return the quantity with all units reduced to their base SI elements.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inDimensionless()¶
Returns the numerical value of a dimensionless quantity.
>>> print(PhysicalField(((2., 3.), (4., 5.))).inDimensionless()) [[ 2. 3.] [ 4. 5.]]
It’s an error to convert a quantity with units
>>> print(PhysicalField(((2., 3.), (4., 5.)), "m").inDimensionless()) Traceback (most recent call last): ... TypeError: Incompatible units
- inRadians()¶
Converts an angular quantity to radians and returns the numerical value.
>>> print(PhysicalField(((2., 3.), (4., 5.)), "rad").inRadians()) [[ 2. 3.] [ 4. 5.]] >>> print(PhysicalField(((2., 3.), (4., 5.)), "deg").inRadians()) [[ 0.03490659 0.05235988] [ 0.06981317 0.08726646]]
As a special case, assumes a dimensionless quantity is already in radians.
>>> print(PhysicalField(((2., 3.), (4., 5.))).inRadians()) [[ 2. 3.] [ 4. 5.]]
It’s an error to convert a quantity with non-angular units
>>> print(PhysicalField(((2., 3.), (4., 5.)), "m").inRadians()) Traceback (most recent call last): ... TypeError: Incompatible units
- inSIUnits()¶
Return the quantity with all units reduced to SI-compatible elements.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> print(e.inSIUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more PhysicalField objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single PhysicalField.
>>> freeze = PhysicalField('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of PhysicalField instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = PhysicalField(314159., 's') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- isCompatible(unit)¶
- itemset(value)¶
Assign the value of a scalar array, performing appropriate conversions.
>>> a = PhysicalField(4., "m") >>> a.itemset(PhysicalField("6 ft")) >>> print(a.allclose("1.8288 m")) 1 >>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> try: ... a.itemset(PhysicalField("6 ft")) ... except IndexError: ... # NumPy 1.7 has changed the exception type ... raise ValueError("can only place a scalar for an array of size 1") Traceback (most recent call last): ... ValueError: can only convert an array of size 1 to a Python scalar >>> a.itemset(PhysicalField("2 min")) Traceback (most recent call last): ... TypeError: Incompatible units
- property itemsize¶
- log()¶
Return the natural logarithm of the PhysicalField
>>> print(numerix.round_(PhysicalField(10).log(), 6)) 2.302585
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1. m").log(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- log10()¶
Return the base-10 logarithm of the PhysicalField
>>> print(numerix.round_(PhysicalField(10.).log10(), 6)) 1.0
The input PhysicalField must be dimensionless
>>> print(numerix.round_(PhysicalField("1. m").log10(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- multiply(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- property numericValue¶
Return the PhysicalField without units, after conversion to base SI units.
>>> print(numerix.round_(PhysicalField("1 inch").numericValue, 6)) 0.0254
- put(indices, values)¶
put is the opposite of take. The values of self at the locations specified in indices are set to the corresponding value of values.
The indices can be any integer sequence object with values suitable for indexing into the flat form of self. The values must be any sequence of values that can be converted to the typecode of self.
>>> f = PhysicalField((1., 2., 3.), "m") >>> f.put((2, 0), PhysicalField((2., 3.), "inch")) >>> print(f) [ 0.0762 2. 0.0508] m
The units of values must be compatible with self.
>>> f.put(1, PhysicalField(3, "kg")) Traceback (most recent call last): ... TypeError: Incompatible units
- ravel()¶
- reshape(shape)¶
Changes the shape of self to that specified in shape
>>> print(PhysicalField((1., 2., 3., 4.), "m").reshape((2, 2))) [[ 1. 2.] [ 3. 4.]] m
The new shape must have the same size as the existing one.
>>> print(PhysicalField((1., 2., 3., 4.), "m").reshape((2, 3))) Traceback (most recent call last): ... ValueError: total size of new array must be unchanged
- property shape¶
Tuple of array dimensions.
- sign()¶
Return the sign of the quantity. The unit is unchanged.
>>> from fipy.tools.numerix import sign >>> print(sign(PhysicalField(((3., -2.), (-1., 4.)), 'm'))) [[ 1. -1.] [-1. 1.]]
- sin()¶
Return the sine of the PhysicalField
>>> print(PhysicalField(numerix.pi/6, "rad").sin()) 0.5 >>> print(PhysicalField(30., "deg").sin()) 0.5
The units of the PhysicalField must be an angle
>>> PhysicalField(30., "m").sin() Traceback (most recent call last): ... TypeError: Incompatible units
- sinh()¶
Return the hyperbolic sine of the PhysicalField
>>> PhysicalField(0.).sinh() 0.0
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").sinh() Traceback (most recent call last): ... TypeError: Incompatible units
- sqrt()¶
Return the square root of the PhysicalField
>>> print(PhysicalField("100. m**2").sqrt()) 10.0 m
The resulting unit must be integral
>>> print(PhysicalField("100. m").sqrt()) Traceback (most recent call last): ... TypeError: Illegal exponent
- subtract(other)¶
Subtract two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') - PhysicalField(10., 'm')) 9.99 km >>> print(PhysicalField(10., 'km') - PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- sum(index=0)¶
Returns the sum of all of the elements in self along the specified axis (first axis by default).
>>> print(PhysicalField(((1., 2.), (3., 4.)), "m").sum()) [ 4. 6.] m >>> print(PhysicalField(((1., 2.), (3., 4.)), "m").sum(1)) [ 3. 7.] m
- take(indices, axis=0)¶
Return the elements of self specified by the elements of indices. The resulting PhysicalField array has the same units as the original.
>>> print(PhysicalField((1., 2., 3.), "m").take((2, 0))) [ 3. 1.] m
The optional third argument specifies the axis along which the selection occurs, and the default value (as in the example above) is 0, the first axis.
>>> print(PhysicalField(((1., 2., 3.), (4., 5., 6.)), "m").take((2, 0), axis = 1)) [[ 3. 1.] [ 6. 4.]] m
- tan()¶
Return the tangent of the PhysicalField
>>> numerix.round_(PhysicalField(numerix.pi/4, "rad").tan(), 6) 1.0 >>> numerix.round_(PhysicalField(45, "deg").tan(), 6) 1.0
The units of the PhysicalField must be an angle
>>> PhysicalField(45., "m").tan() Traceback (most recent call last): ... TypeError: Incompatible units
- tanh()¶
Return the hyperbolic tangent of the PhysicalField
>>> print(numerix.allclose(PhysicalField(1.).tanh(), 0.761594155956)) True
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").tanh() Traceback (most recent call last): ... TypeError: Incompatible units
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
Return human-readable form of a physical quantity
>>> p = PhysicalField(value = (3., 3.14159), unit = "eV") >>> print(p.tostring(precision = 3, separator = '|')) [ 3. | 3.142] eV
- property unit¶
Return the unit object of self.
>>> PhysicalField("1 m").unit <PhysicalUnit m>
- class fipy.PowerLawConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTermThe discretization for this
Termis given by\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P +(1-\alpha_f)\phi_A\) and \(\alpha_f\) is calculated using the power law scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- exception fipy.PreconditionerNotPositiveDefiniteWarning(solver, iter, relres)¶
Bases:
PreconditionerWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.PreconditionerWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ResidualTerm(equation, underRelaxation=1.0)¶
Bases:
_ExplicitSourceTermThe ResidualTerm is a special form of explicit SourceTerm that adds the residual of one equation to another equation. Useful for Newton’s method.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- exception fipy.ScalarQuantityOutOfRangeWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ScharfetterGummelFaceVariable(*args, **kwds)¶
Bases:
_CellToFaceVariable- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tupleofint) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self, \(\vec{u}\),
\[\nabla\cdot\vec{u} \approx \frac{\sum_f (\vec{u}\cdot\hat{n})_f A_f}{V_P}\]- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c0 = Constraint(0., where=m.facesLeft) >>> v.constrain(c0) >>> c1 = Constraint(3., where=m.facesRight) >>> v.faceValue.constrain(c1) >>> print(v.faceValue) [ 0. 1. 2. 3.] >>> v.faceValue.release(constraint=c0) >>> print(v.faceValue) [ 0.5 1. 2. 3. ] >>> v.faceValue.release(constraint=c1) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
Create a temporary file shared by all MPI ranks.
The file is created as NamedTemporaryFile would do it. The name of the returned file-like object is accessible as its
nameattribute. The file will be automatically deleted when it is closed unless the delete argument is set to False.>>> from fipy.tools import SharedTemporaryFile, parallelComm >>> with SharedTemporaryFile(mode='w+', suffix=".tmp") as tmpFile: ... # write on processor 0 ... if parallelComm.procID == 0: ... _ = tmpFile.write("shared text") ... ... parallelComm.Barrier() ... ... # read on all processors ... _ = tmpFile.seek(0) ... txt = tmpFile.read() >>> print(txt) shared text
- Parameters:
prefix (str) – As for mkstemp
suffix (str) – As for mkstemp
dir (str) – As for mkstemp
mode (str) – The mode argument to io.open (default “w+b”)
buffering (int) – The buffer size argument to io.open (default -1)
encoding (str or None) – The encoding argument to io.open (default None)
newline (str or None) – The newline argument to io.open (default None)
delete (bool) – Whether the file is deleted on close (default True)
communicator (CommWrapper) – MPI communicator describing ranks to share with. A duck-typed object with procID and Nproc attributes is sufficient.
- Return type:
file-like object
See also
- class fipy.SkewedGrid2D(dx=1.0, dy=1.0, nx=None, ny=1, rand=0, *args, **kwargs)¶
Bases:
Mesh2DCreates a 2D grid mesh with horizontal faces numbered first and then vertical faces. The points are skewed by a random amount (between rand and -rand) in the X and Y directions.
Note
This Mesh only operates in serial
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property physicalShape¶
Return physical dimensions of Grid2D.
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property shape¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- exception fipy.SolutionVariableNumberError(s='Different number of solution variables and equations.')¶
Bases:
Exception- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.SolutionVariableRequiredError(s='The solution variable needs to be specified.')¶
Bases:
Exception- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.Solver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
objectThe base LinearXSolver class.
Attention
This class is abstract. Always create one of its subclasses.
Create a Solver object.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- exception fipy.SolverConvergenceWarning(solver, iter, relres)¶
Bases:
Warning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.SphericalGrid1D(dr=None, nr=None, Lr=None, dx=1.0, nx=None, Lx=None, origin=(0,), overlap=2, communicator=DummyComm())¶
Create a 1D spherical mesh
Factory function to select between
SphericalUniformGrid1DandSphericalNonUniformGrid1D. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
nr (int) – Number of cells in the radial direction. Alternative: nx.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialCommto create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm).
- exception fipy.StagnatedSolverWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.SurfactantConvectionVariable(*args, **kwds)¶
Bases:
FaceVariableConvection coefficient for the ConservativeSurfactantEquation. The coefficient only has a value for a negative distanceVar.
Simple one dimensional test:
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> mesh = Grid2D(nx = 3, ny = 1, dx = 1., dy = 1.) >>> from fipy.variables.distanceVariable import DistanceVariable >>> distanceVar = DistanceVariable(mesh, value = (-.5, .5, 1.5)) >>> ## answer = numerix.zeros((2, mesh.numberOfFaces),'d') >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[0, 7] = -1 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Change the dimensions:
>>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .25) >>> distanceVar = DistanceVariable(mesh, value = (-.25, .25, .75)) >>> answer[0, 7] = -.5 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Two dimensional example:
>>> mesh = Grid2D(nx = 2, ny = 2, dx = 1., dy = 1.) >>> distanceVar = DistanceVariable(mesh, value = (-1.5, -.5, -.5, .5)) >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[1, 2] = -.5 >>> answer[1, 3] = -1 >>> answer[0, 7] = -.5 >>> answer[0, 10] = -1 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Larger grid:
>>> mesh = Grid2D(nx = 3, ny = 3, dx = 1., dy = 1.) >>> distanceVar = DistanceVariable(mesh, value = (1.5, .5, 1.5, ... .5, -.5, .5, ... 1.5, .5, 1.5)) >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[1, 4] = .25 >>> answer[1, 7] = -.25 >>> answer[0, 17] = .25 >>> answer[0, 18] = -.25 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self, \(\vec{u}\),
\[\nabla\cdot\vec{u} \approx \frac{\sum_f (\vec{u}\cdot\hat{n})_f A_f}{V_P}\]- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.SurfactantVariable(*args, **kwds)¶
Bases:
CellVariableThe SurfactantVariable maintains a conserved volumetric concentration on cells adjacent to, but in front of, the interface. The value argument corresponds to the initial concentration of surfactant on the interface (moles divided by area). The value held by the SurfactantVariable is actually a volume density (moles divided by volume).
A simple 1D test:
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(dx = 1., nx = 4) >>> from fipy.variables.distanceVariable import DistanceVariable >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-1.5, -0.5, 0.5, 941.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, (0, 0., 1., 0))) 1
A 2D test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (1.5, 0.5, 1.5, ... 0.5, -0.5, 0.5, ... 1.5, 0.5, 1.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, (0, 1, 0, 1, 0, 1, 0, 1, 0))) 1
Another 2D test case:
>>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-0.5, 0.5, 0.5, 1.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, ... (0, numerix.sqrt(2), numerix.sqrt(2), 0))) 1
- Parameters:
value (float or array_like) – The initial value.
distanceVar (DistanceVariable) –
name (str) – The name of the variable.
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- property interfaceVar¶
Returns the SurfactantVariable rendered as an _InterfaceSurfactantVariable which evaluates the surfactant concentration as an area concentration the interface rather than a volumetric concentration.
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.TSVViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
AbstractViewer“Views” one or more variables in tab-separated-value format.
Output is a list of coordinates and variable values at each cell center.
File contents will be, e.g.:
title x y ... var0 var2 ... 0.0 0.0 ... 3.14 1.41 ... 1.0 0.0 ... 2.72 0.866 ... : :
Creates a TSVViewer.
Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.
All variables must have the same mesh.
It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
“plot” the coordinates and values of the variables to filename. If filename is not provided, “plots” to stdout.
>>> from fipy.meshes import Grid1D >>> m = Grid1D(nx = 3, dx = 0.4) >>> from fipy.variables.cellVariable import CellVariable >>> v = CellVariable(mesh = m, name = "var", value = (0, 2, 5)) >>> TSVViewer(vars = (v, v.grad)).plot() x var var_gauss_grad_x 0.2 0 2.5 0.6 2 6.25 1 5 3.75
>>> from fipy.meshes import Grid2D >>> m = Grid2D(nx = 2, dx = .1, ny = 2, dy = 0.3) >>> v = CellVariable(mesh = m, name = "var", value = (0, 2, -2, 5)) >>> TSVViewer(vars = (v, v.grad)).plot() x y var var_gauss_grad_x var_gauss_grad_y 0.05 0.15 0 10 -3.33333333333333 0.15 0.15 2 10 5 0.05 0.45 -2 35 -3.33333333333333 0.15 0.45 5 35 5
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- exception fipy.TermMultiplyError(s='Must multiply terms by int or float.')¶
Bases:
Exception- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.TransientTerm(coeff=1.0, var=None)¶
Bases:
CellTermThe TransientTerm represents
\[\int_V \frac{\partial (\rho \phi)}{\partial t} dV \simeq \frac{(\rho_{P} \phi_{P} - \rho_{P}^\text{old} \phi_P^\text{old}) V_P}{\Delta t}\]where \(\rho\) is the coeff value.
The following test case verifies that variable coefficients and old coefficient values work correctly. We will solve the following equation
\[\frac{ \partial \phi^2 } { \partial t } = k.\]The analytic solution is given by
\[\phi = \sqrt{ \phi_0^2 + k t },\]where \(\phi_0\) is the initial value.
>>> phi0 = 1. >>> k = 1. >>> dt = 1. >>> relaxationFactor = 1.5 >>> steps = 2 >>> sweeps = 8
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 1) >>> from fipy.variables.cellVariable import CellVariable >>> var = CellVariable(mesh = mesh, value = phi0, hasOld = 1) >>> from fipy.terms.transientTerm import TransientTerm >>> from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
Relaxation, given by relaxationFactor, is required for a converged solution.
>>> eq = TransientTerm(var) == ImplicitSourceTerm(-relaxationFactor) \ ... + var * relaxationFactor + k
A number of sweeps at each time step are required to let the relaxation take effect.
>>> from builtins import range >>> for step in range(steps): ... var.updateOld() ... for sweep in range(sweeps): ... eq.solve(var, dt = dt)
Compare the final result with the analytical solution.
>>> from fipy.tools import numerix >>> print(var.allclose(numerix.sqrt(k * dt * steps + phi0**2))) 1
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.Tri2D(dx=1.0, dy=1.0, nx=1, ny=1, _RepresentationClass=<class 'fipy.meshes.representations.gridRepresentation._Grid2DRepresentation'>, _TopologyClass=<class 'fipy.meshes.topologies.meshTopology._Mesh2DTopology'>)¶
Bases:
Mesh2DThis class creates a mesh made out of triangles. It does this by starting with a standard Cartesian mesh (Grid2D) and dividing each cell in that mesh (hereafter referred to as a “box”) into four equal parts with the dividing lines being the diagonals.
Creates a 2D triangular mesh with horizontal faces numbered first then vertical faces, then diagonal faces. Vertices are numbered starting with the vertices at the corners of boxes and then the vertices at the centers of boxes. Cells on the right of boxes are numbered first, then cells on the top of boxes, then cells on the left of boxes, then cells on the bottom of boxes. Within each of the “sub-categories” in the above, the vertices, cells and faces are numbered in the usual way.
- Parameters:
dx (float) – The X and Y dimensions of each “box”. If dx <> dy, the line segments connecting the cell centers will not be orthogonal to the faces.
dy (float) – The X and Y dimensions of each “box”. If dx <> dy, the line segments connecting the cell centers will not be orthogonal to the faces.
nx (int) – The number of boxes in the X direction and the Y direction. The total number of boxes will be equal to nx * ny, and the total number of cells will be equal to 4 * nx * ny.
ny (int) – The number of boxes in the X direction and the Y direction. The total number of boxes will be equal to nx * ny, and the total number of cells will be equal to 4 * nx * ny.
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property physicalShape¶
Return physical dimensions of Grid2D.
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property shape¶
- property x¶
Equivalent to using
cellCenters[0].>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters[1].>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters[2].>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.UniformNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariableRepresents a uniform distribution of random numbers.
We generate noise on a uniform Cartesian mesh
>>> from fipy.meshes import Grid2D >>> noise = UniformNoiseVariable(mesh=Grid2D(nx=100, ny=100))
and histogram the noise
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution=noise, dx=0.01, nx=120, offset=-.1)
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, ... datamin=0, datamax=1) ... histoplot = Viewer(vars=histogram)
>>> from builtins import range >>> for i in range(10): ... noise.scramble() ... if __name__ == '__main__': ... viewer.plot() ... histoplot.plot()
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
\[<\phi>_\text{vol} = \frac{\sum_\text{cells} \phi_\text{cell} V_\text{cell}} {\sum_\text{cells} V_\text{cell}}\]>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{self} \cdot ext{other}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return \(\nabla \phi\) as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()insteadReturn \(\nabla \phi\) as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
\[\phi_f = (\phi_1 - \phi_2) \frac{d_{f2}}{d_{12}} + \phi_2\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return \(\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f\) as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value.
- property grad¶
Return \(\nabla \phi\) as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
\[\phi_f = \frac{\phi_1 \phi_2}{(\phi_2 - \phi_1) \frac{d_{f2}}{d_{12}} + \phi_1}\]>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return \(\nabla \phi\), which is determined by solving for \(\nabla \phi\) in the following matrix equation,
\[\nabla \phi \cdot \sum_f d_{AP}^2 \vec{n}_{AP} \otimes \vec{n}_{AP} = \sum_f d_{AP}^2 \left( \vec{n} \cdot \nabla \phi \right)_{AP}\]The matrix equation is derived by minimizing the following least squares sum,
\[F \left( \phi_x, \phi_y \right) = \sqrt{\sum_f \left( d_{AP} \vec{n}_{AP} \cdot \nabla \phi - d_{AP} \left( \vec{n}_{AP} \cdot \nabla \phi \right)_{AP} \right)^2 }\]Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
\[\begin{split}\phi_f = \begin{cases} \phi_1& \text{when $|\phi_1| \le |\phi_2|$},\\ \phi_2& \text{when $|\phi_2| < |\phi_1|$},\\ 0 & \text{when $\phi1 \phi2 < 0$} \end{cases}\end{split}\]>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
\[ext{other} \cdot ext{self}\]Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.UpwindConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractUpwindConvectionTermThe discretization for this
Termis given by\[\int_V \nabla \cdot (\vec{u} \phi)\,dV \simeq \sum_{f} (\vec{n} \cdot \vec{u})_f \phi_f A_f\]where \(\phi_f=\alpha_f \phi_P +(1-\alpha_f)\phi_A\) and \(\alpha_f\) is calculated using the upwind convection scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.VTKCellViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
VTKViewerRenders CellVariable data in VTK format
Creates a VTKViewer
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- class fipy.VTKFaceViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
VTKViewerRenders _MeshVariable data in VTK format
Creates a VTKViewer
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1, the name ofself.vars[0], otherwise"".)
- fipy.VTKViewer(vars, title=None, limits={}, **kwlimits)¶
Generic function for creating a VTKViewer.
The VTKViewer factory will search the module tree and return an instance of the first VTKViewer it finds of the correct dimension and rank.
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- class fipy.VanLeerConvectionTerm(coeff=1.0, var=None)¶
Bases:
ExplicitUpwindConvectionTermCreate a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector \(\vec{e}=\mathsf{L}\vec{x}_\text{old} - \vec{b}\)
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
norm (float) – The L2 norm of residual, \(\|\vec{r}\|_2\)
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tupleofBoundaryCondition) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\) in the residualVector member of Term
cacheError (bool) – If True, use the residual vector \(\vec{r}\) to solve \(\mathsf{L}\vec{e}=\vec{r}\) for the error vector \(\vec{e}\) and store it in the errorVector member of Term
- Returns:
residual – The residual vector \(\vec{r}=\mathsf{L}\vec{x} - \vec{b}\)
- Return type:
- class fipy.Variable(*args, **kwds)¶
Bases:
objectLazily evaluated quantity with units.
Using a
Variablein a mathematical expression will create an automatic dependencyVariable, e.g.,>>> a = Variable(value=3) >>> b = 4 * a >>> b (Variable(value=array(3)) * 4) >>> b() 12
Changes to the value of a
Variablewill automatically trigger changes in any dependentVariableobjects>>> a.setValue(5) >>> b (Variable(value=array(5)) * 4) >>> print(b()) 20
Create a Variable.
>>> Variable(value=3) Variable(value=array(3)) >>> Variable(value=3, unit="m") Variable(value=PhysicalField(3,'m')) >>> Variable(value=3, unit="m", array=numerix.zeros((3, 2), 'l')) Variable(value=PhysicalField(array([[3, 3], [3, 3], [3, 3]]),'m'))
- Parameters:
value (int or float or array_like) –
unit (str or PhysicalUnit) – The physical units of the variable
array (ndarray, optional) – The storage array for the Variable
name (str) – The user-readable name of the Variable
cached (bool) – whether to cache or always recalculate the value
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
picklethe Variable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickledpersistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool) – The constraint mask or index specifying the location of the constraint
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None, axis=0)¶
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property mag¶
The magnitude of the
Variable, e.g., \(|\vec{\psi}| = \sqrt{\vec{\psi}\cdot\vec{\psi}}\).
- max(axis=None)¶
- min(axis=None)¶
- property name¶
- property numericValue¶
- put(indices, value)¶
- ravel()¶
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
Tuple of array dimensions.
>>> Variable(value=3).shape () >>> numerix.allequal(Variable(value=(3,)).shape, (1,)) True >>> numerix.allequal(Variable(value=(3, 4)).shape, (2,)) True
>>> Variable(value="3 m").shape () >>> numerix.allequal(Variable(value=(3,), unit="m").shape, (1,)) True >>> numerix.allequal(Variable(value=(3, 4), unit="m").shape, (2,)) True
- std(axis=None, **kwargs)¶
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- exception fipy.VectorCoeffError(s='The coefficient must be a vector value.')¶
Bases:
TypeError- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.Viewer(vars, title=None, limits={}, FIPY_VIEWER=None, **kwlimits)¶
Generic function for creating a Viewer.
The Viewer factory will search the module tree and return an instance of the first Viewer it finds that supports the dimensions of vars. Setting the FIPY_VIEWER environment variable to either matplotlib, mayavi, tsv, or vtk will specify the viewer.
The kwlimits or limits parameters can be used to constrain the view. For example:
Viewer(vars=some1Dvar, xmin=0.5, xmax=None, datamax=3)
or:
Viewer(vars=some1Dvar, limits={'xmin': 0.5, 'xmax': None, 'datamax': 3})
will return a viewer that displays a line plot from an x value of 0.5 up to the largest x value in the dataset. The data values will be truncated at an upper value of 3, but will have no lower limit.
- Parameters:
vars (CellVariable or list) – the Variable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
FIPY_VIEWER – a specific viewer to attempt (possibly multiple times for multiple variables)
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- class fipy.Vitals¶
Bases:
DocumentReturns XML formatted information about current FiPy environment
- ATTRIBUTE_NODE = 2¶
- CDATA_SECTION_NODE = 4¶
- COMMENT_NODE = 8¶
- DOCUMENT_FRAGMENT_NODE = 11¶
- DOCUMENT_NODE = 9¶
- DOCUMENT_TYPE_NODE = 10¶
- ELEMENT_NODE = 1¶
- ENTITY_NODE = 6¶
- ENTITY_REFERENCE_NODE = 5¶
- NOTATION_NODE = 12¶
- PROCESSING_INSTRUCTION_NODE = 7¶
- TEXT_NODE = 3¶
- __slots__ = ('_elem_info', 'doctype', '_id_search_stack', 'childNodes', '_id_cache')¶
- __str__()¶
Return str(self).
- actualEncoding = None¶
- appendChild(child)¶
- appendInfo(name, svnpath=None, **kwargs)¶
append some additional information, possibly about a project under a separate svn repository
- async_ = False¶
- attributes = None¶
- childNodes¶
- dictToXML(d, name)¶
- doctype¶
- property documentElement¶
Top-level element of this document.
- documentURI = None¶
- encoding = None¶
- errorHandler = None¶
- property firstChild¶
First child node, or None.
- implementation = <xml.dom.minidom.DOMImplementation object>¶
- property lastChild¶
Last child node, or None.
- property localName¶
Namespace-local name of this node.
- namespaceURI = None¶
- nextSibling = None¶
- nodeName = '#document'¶
- nodeType = 9¶
- nodeValue = None¶
- ownerDocument = None¶
- parentNode = None¶
- prefix = None¶
- previousSibling = None¶
- save(fname)¶
- standalone = None¶
- strictErrorChecking = False¶
- svn(*args)¶
- svncmd(cmd, *args)¶
- tupleToXML(t, name, keys=None)¶
- version = None¶
- fipy.openMSHFile(name, dimensions=None, coordDimensions=None, communicator=DummyComm(), overlap=1, mode='r', background=None)¶
Open a Gmsh MSH file
- Parameters:
filename (str) – Gmsh output file
dimensions (int) – Dimension of mesh
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
mode (str) – Beginning with r for reading and w for writing. The file will be created if it doesn’t exist when opened for writing; it will be truncated when opened for writing. Add a b to the mode for binary files.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- fipy.openPOSFile(name, communicator=DummyComm(), mode='w')¶
Open a Gmsh POS post-processing file
FiPy